如何使用Unix命令一个Django开发服务器运行时? (图片提供) [英] How do I use unix commands while a Django development server is running? (picture provided)

查看:181
本文介绍了如何使用Unix命令一个Django开发服务器运行时? (图片提供)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如果我可以运行不退出服务器的Unix命令。如果是这样,怎么样?我用Bash脚本来启动服务器,我想有一个退出当用户presses停止按钮来运行服务器Bash脚本。然而,在运行Bash脚本的时候,似乎没有命令就必须执行,但只是挂在那里。

I was wondering if I could run unix commands without quitting the server. If so, how? I used a Bash script to start the server, and I want to have a Bash script that quits the server to run when users presses the stop button. However, when the Bash script is run, the commands don't seem to be executed, but just hangs there.

我试着运行定影-k 8000 / TCP ,但这显然不是我应该怎样做这个,因为它没有运行。谁能给我个忙吗?

I tried running fuser -k 8000/tcp, but this clearly isn't how I am supposed to be doing this, as it did not run. Can anyone give me a hand?

推荐答案

您可以在后台运行开发服务器

You can run the development server in the background as

nohup python manage.py runserver 0.0.0.0:8000 &

和消息和日志写在nohup.out文件。

and the messages and logs are written in the file nohup.out.

和可以执行你的意志的nohup的操作之后的任何UNIX命令。有关的bash脚本杀开发服务器,你可以找到 PID 开发服务器,并使用杀了它命令。

And you can perform any unix commands after the nohup operation at your will. Regarding, the bash script to kill the development server, you can find the pid of the development server and kill it using kill command.

这篇关于如何使用Unix命令一个Django开发服务器运行时? (图片提供)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆