0

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?

4 Answers 4

2

If you change session (log out and come back), there is no chance you'll see your script as job.

try ps instead.

ps -u myuser

replacing myuser with actual login..

0
0

If your job is visible when you use jobs -l you can remove it from your session with disown

Another way to keep script running is to use the screen tool.

0

Try redirecting all I/O streams

nohup script.py < /dev/null > output.out 2> error.out &
0

Long expalation:
Background running process (job) is always bound to particular terminal:

[11]user@lab7-11:~> nohup ./test.sh > out &
[1] 39978

[11]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 jobs output:

[11]user@lab7-11:~> jobs -l
[1]+ 39978 Running                 nohup ./test.sh > out &

After you've closed that terminal, your job became daemon and is not more bound to terminal

[7]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 job

Short explanation: Your script was not killed - it became daemon.

2
  • Thanks. With ps I can see that process is still running. Thanks a lot Feb 16, 2016 at 14:49
  • If this helped, you can accept this as answer :) Feb 16, 2016 at 14:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .