Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # create a variable with each monitored process on a separate line
- processes="nzbget"
- # use while [ 1 ] to loop forever
- while [ 1 ]
- do
- # the for loop will automatically split the $processes variable by newline
- for p in $processes
- do
- # if the process $p is running, pidof $p will return its process ids (one
- # for each instance of the process). otherwise, it will return an empty
- # list and the following if condition will return true
- if [ ! "$(pidof $p)" ]
- then
- # print an error message to the console window and restart the process.
- # the ampersand starts it as a background process.
- echo -e "\n\n***********\nRESTARTING $p PROCESS\n**********\n"
- /home/gravyface/nzbget -D &
- fi
- done
- # Sleep for a few seconds so that the loop doesn't keep querying for process
- # ids over and over.
- sleep 10
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement