4

I have a Raspberry Pi running Raspbian OS.

After login via SSH, I ran a python script via nohup:

nohup python3 start.py </dev/null >/dev/null &

Then I logout. The python process was still running.

But after two days or several days, the python process was end. There is no error in log.

Can anyone give me some tips?

comphilip
  • 500
  • 5
  • 15
  • nohup is not a stable solution. Upgrade or reinstall linux which support systemd and use systemd service instead. – comphilip Oct 30 '20 at 15:46

1 Answers1

4

Try redirecting stderr as well:

nohup python3 start.py </dev/null >/dev/null 2>&1 &

Also I don't think this is really helpful but just add disown anyway:

nohup python3 start.py </dev/null >/dev/null 2>&1 &
disown
konsolebox
  • 72,135
  • 12
  • 99
  • 105
  • 1
    Thanks for answering. The nohup solution is not robust. I following the answer and it works well https://stackoverflow.com/questions/696839/how-do-i-write-a-bash-script-to-restart-a-process-if-it-dies/697064#697064 – comphilip Aug 29 '17 at 05:03
  • @comphilip `( python3 start.py & disown ) &>/dev/null – konsolebox Aug 30 '17 at 19:39