Advertisement
TheHotBot

Start/stop script for applications with log

Jun 2nd, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.66 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ########################################
  4. ## execute with "nohup sh monitor.sh" ##
  5. ## or run with crontab                ##
  6. ## Phew/NeverW8 and TheHotBot         ##
  7. ########################################
  8.  
  9.  
  10. SERVICE_HOME="opt/data/log/ls/testapp"
  11. LOG_FILE=$SERVICE_HOME/servicemix.log
  12.  
  13. ERROR_STRING=I-AM-A-ERROR
  14.  
  15. tail -Fn0 $LOG_FILE | \
  16. while read line ; do
  17.         echo "$line" | grep "$ERROR_STRING"
  18.         if [ $? = 0 ]
  19.         then
  20.              
  21.         /etc/init.d/APPLICATION stop && sleep 300 && /etc/init.d/APPLICATION start
  22.         echo  $(date && echo "Restarting ")  >> restartdate.log
  23.         echo  "-----------"  >> restartdate.log
  24.         fi
  25. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement