Question

Process id dismiss when ssh connect again

Posted December 21, 2017 1.8k views
UbuntuDebianPython FrameworksDevelopment

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.

×
1 answer

It’s possible that the program has crashed. I would recommend using screen instead of nohup. You can install it by running

sudo apt-get install screen

Then, you can start a session by running screen. This will launch a new bash process that you can run python patrol.py in. First, enable logging in order to identify the issue by pressing Ctrl-a, H. Run your program, and press Ctrl-a, d to detach from the session, which will keep it running in the background. You can now disconnect from your Droplet and the screen session will keep running. Keep an eye on the log file and see if it has any information if the process quits again.

Submit an Answer