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?

Arthur Zangiev
  • 101
  • 1
  • 1

4 Answers4

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..

Archemar
  • 1,369
  • 11
  • 19
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.

Django Janny
  • 435
  • 5
  • 5
0

Try redirecting all I/O streams

nohup script.py < /dev/null > output.out 2> error.out &
Laurentiu Roescu
  • 2,266
  • 17
  • 17
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.

user1700494
  • 1,642
  • 2
  • 12
  • 21