0

I have a process running on a raspberry pi. After ssh ing into in to the process is started like this:

nohup .../blah/blah &

IIUC this allows me to log out of the pi and the process keeps running. However it dies sometimes, and I have to log in and manually restart it. Is there a way to monitor it and have it restart itself?

  • 1
    For a more permanent solution, you could consider creating a systemd service for it. – rudib Oct 5 '18 at 21:17
3

Run it in an infinite loop:

#!/bin/sh

while true; do
    .../blah/blah
done

This would be a script that you start with nohup in the background. When blah dies, it is immediately restarted, until the script is killed.

A variation that ends the loop if a file called stopme appears in the working directory of the script (a check is only made before (re-)starting blah):

#!/bin/sh

while true; do
    [ -e stopme ] && break
    .../blah/blah
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.