Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2015
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. set -x
  4. count=0
  5.  
  6. while :
  7. do
  8. if test $count -lt 40
  9. then
  10. mail -s "server.js started just now" myemail@gmail.com < /dev/null
  11. fi
  12.  
  13. count=`expr $count + 1`
  14.  
  15. date1=`date +%s` #get unix time
  16.  
  17. cd /home/login/railways/nodejs
  18.  
  19. echo "Starting time is $date1"
  20. /usr/bin/nodejs server.js >> server.log
  21.  
  22. date2=`date +%s` #get unix time
  23.  
  24.  
  25. if test $date1 -eq $date2
  26. then
  27. msg="exiting as process has failed"
  28. echo $msg
  29. if test $count -lt 40
  30. then
  31. mail -s $msg myemail@gmail.com < /dev/null
  32. fi
  33. sleep 10
  34. fi
  35.  
  36.  
  37. echo "restarting the process"
  38.  
  39.  
  40. sleep 1
  41. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement