我编写了一个bash脚本来启动Django开发服务器,但是,我也希望能够在服务器与bash脚本一起运行时退出服务器。我正在为Koding.com编写一个Web应用程序,该应用程序通过按一个按钮运行bash脚本,在链接到用户个人VM的在线终端中启动Django进程,我希望用户能够通过以下方式结束该进程:同时按下一个按钮。我知道控件C会结束该过程,但是我无法在bash脚本中找到如何做到这一点。我该怎么做呢?谢谢!
UPDATE: I ultimately combined my selected answer for this question and this answer from another question I asked (how to run unix commands in django shell) to solve my problem: https://stackoverflow.com/a/22777849/2181017
You can kill the process listening on 8000/TCP:
fuser -k 8000/tcp
The fuser
command shows which processes are using the named files, sockets, or filesystems and the -k
option kills them as well.
Wait, just to clarify, there's no way to temporarily exit that django shell thing so that I could run a unix command?
启动开发服务器时,它将在前台运行,从而阻止提示。您可以通过单击暂停正在前台运行的任务,CTRL+Z
然后将其发送到后台运行bg
命令(我假设您正在运行bash shell或相似的命令)。该jobs
命令将列出暂停的任务或在后台运行的任务。您可以使用fg
命令将任务置于前台。
请参考bash手册页(man bash
)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句