Reputation: 17233
I wanted to know what my options are of starting
./manage.py runworker
in the background. I tried doing this
python ./manage.py runworker 2>>./daphneWorker.log >&2
but that does not seem to work either. Any suggestions on how I can make it run in the background ?
Upvotes: 1
Views: 2374
Reputation: 3424
You can use nohup
to keep it running in background.
nohup python manage.py runserver 0.0.0.0:80 &
nohup prevents the command from being aborted automatically when you log out or exit the shell.
In order to stop the process running the server on port 80
netstat -nlp | grep :80
The above command gives you the processId or PID
Then:
kill PID
And in case you would like to log output
nohup python manage.py runserver 0.0.0.0:80 > myLog.out &
Upvotes: 5
Reputation: 103
I always use screen
tool for this kind of jobs. It is a virtual terminal that always run even if your ssh disconnected.
First use screen
command to create screen window within the same shell. It will display you bunch of info just press enter or spacebar. Than you come up with similar terminal of yours. Start your app in that terminal:
./manage.py runworker
now your app is running and you can detach from screen window with ctrl+a d
.
This will return you to your real terminal.
When you want to come back your detached screen window that is running in background just type screen -dr
or if you have multiple detached screen windows first list all of them with screen -ls
and than re attach the window you desire with screen -r [number_of_window]
. When you are done you can kill screen window with ctrl+a k
from inside the screen window.
Upvotes: 3