In order to execute a task background, I use nohup
command.
# nohup python patrol.py &
Everything works well but when I close ssh connection and connect it again, I find the process id does not exist.The python task sends a request to an api every 20 minutes.From the api server console, I find the process still works.However from ps
command I can not find the process id
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
It’s possible that the program has crashed. I would recommend using
screen
instead ofnohup
. You can install it by runningThen, you can start a session by running
screen
. This will launch a new bash process that you can runpython patrol.py
in. First, enable logging in order to identify the issue by pressingCtrl
-a
,H
. Run your program, and pressCtrl
-a
,d
to detach from the session, which will keep it running in the background. You can now disconnect from your Droplet and thescreen
session will keep running. Keep an eye on the log file and see if it has any information if the process quits again.