Script started with nohup get killed when leave terminal – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.
But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, ubuntu, python, nohup, .
I need to run some python scripts with infinite loop on ubuntu server (Amazon EC2). And I really like the idea to use nohup as it is simple and I can have output.out log file. I start script like
nohup script.py > output.out &
The process get started. I check it with jobs -l all fine.
Then I close the terminal and log back check processes with jobs -l and I can’t see it any more. Can you advise me what am I doing wrong?
If you change session (log out and come back), there is no chance you’ll see your script as job.
ps -u myuser
replacing myuser with actual login..
If your job is visible when you use
jobs -l you can remove it from your session with
Another way to keep script running is to use the
Try redirecting all I/O streams
nohup script.py < /dev/null > output.out 2> error.out &
Background running process (job) is always bound to particular terminal:
user@lab7-11:~> nohup ./test.sh > out &  39978 user@lab7-11:~> ps aux |grep 39978 user 39978 0.0 0.0 106096 1156 pts/11 S 06:15 0:00 bash ./test.sh
While it is bound to terminal, you are able to see it in
user@lab7-11:~> jobs -l + 39978 Running nohup ./test.sh > out &
After you’ve closed that terminal, your job became daemon and is not more bound to terminal
user@lab7-11:~> ps aux |grep 39978 user 39978 0.0 0.0 106096 1156 ? S 06:15 0:00 bash ./test.sh
So, at this stage, you can check state of your process via
ps as suggested by @Archemar but not via
Your script was not killed – it became daemon.