1

So in order to keep my simple blog running permanently, i used the nohup command:

nohup python manage.py runserver 0.0.0.0:8000

Everything worked perfectly, my blog keep running even though i logged out of Terminal. But now I don't want to run it anymore, so I tried to kill it but I got an error:

# ps aux | grep nohup
root     23427  0.0  0.0 103308   860 pts/1    S+   11:56   0:00 grep nohup
# kill -9 23427
bash: kill: (23427) - No such process

And of course, my blog still keeps running, so I don't understand what just happened. Is there any way to deal with this problem?

9

You didn't have a nohup process. Your search found an instance of grep which was searching for nohup, but by the time you got your next prompt, the grep process had already terminated. You're actually looking for a python instance.

ps aux | grep python | grep manage.py # This will show you the process you're looking for
kill $(ps aux | grep python | grep manage.py | awk '{print $2}') # This will kill it.
  • The grep process had already terminated? Could you tell me what would be the reason and what should i do next, please? – The One Apr 28 '16 at 3:10
  • 1
    Your command, ps aux | grep nohup was searching the process list for any instance of any process (including paramaters) matching nohup. While it was running, it found itself, because grep nohup contains the string nohup. The grep then finished, so when you tried to kill the grep process you found, which had already self-terminated, you were rightly told there was no such process. – DopeGhoti Apr 28 '16 at 3:13
  • It worked! I was able to kill that process! Thanks! – The One Apr 28 '16 at 3:18
  • 2
    Pleased to have been of service. – DopeGhoti Apr 28 '16 at 3:22
  • 2
    or just kill $(ps aux | awk '/ [m]anage.py/ {print $2}'). Better yet, run manage.py inside screen or tmux or similar rather than with nohup. Then you easily can re-attach to the screen/tmux/whatever session later if/when you need to. You can attach/detach/re-attach as many times as you like. – cas Apr 28 '16 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.