0

python manage.py runserver 0.0.0.0:8000
how to make this command running if terminal close

for now i use screen and it works any other way to do that? i mean for production how to link it to ngix or apahce in ubuntu server?

Ivan
  • 769
  • If your question is not a duplicate please [edit] it to explain why. So far it still looks like a duplicate. – Seth Feb 01 '15 at 19:21

2 Answers2

3

You could try to run your Python script with the nohup command infront. Nohup will make the script immume to hangups.

example

nohup python myscript.py &

Your output will be send to nohup.out.

David
  • 145
  • 6
  • You could also use forever. This is a nodejs script but you can run Python scripts with it. link – David Jan 29 '15 at 11:12
  • This will make the process go to background, but it will not prevent it from being killed if you exit the session. To do that one has to use screen or similar, where, as you pointed out, you can use the nohup in addition to screen... – DarkCygnus Nov 14 '18 at 17:04
  • nohup python manage.py runserver & this worked for me. to kill it you need to find the pid using ps aux | grep manage.py then kill it using kill pid – suhailvs Sep 28 '21 at 03:36
1

Very nice alternative to screen is program called tmux. I use it constantly for daily basis.

Tip:

To dump process into same terminal, runcd any command you'd like, then:

  1. Ctrl + Z - to stop process
  2. write bg - it will dump process to the background
Maciej Sypień
  • 128
  • 1
  • 1
  • 8