By justcoxier
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
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.