Advertisement
Guest User

Untitled

a guest
Jul 31st, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # create a variable with each monitored process on a separate line
  4. processes="nzbget"
  5. # use while [ 1 ] to loop forever
  6. while [ 1 ]
  7. do
  8. # the for loop will automatically split the $processes variable by newline
  9. for p in $processes
  10. do
  11. # if the process $p is running, pidof $p will return its process ids (one
  12. # for each instance of the process). otherwise, it will return an empty
  13. # list and the following if condition will return true
  14. if [ ! "$(pidof $p)" ]
  15. then
  16. # print an error message to the console window and restart the process.
  17. # the ampersand starts it as a background process.
  18. echo -e "\n\n***********\nRESTARTING $p PROCESS\n**********\n"
  19. /home/gravyface/nzbget -D &
  20. fi
  21. done
  22. # Sleep for a few seconds so that the loop doesn't keep querying for process
  23. # ids over and over.
  24. sleep 10
  25.  
  26. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement