daily pastebin goal
10%
SHARE
TWEET

Start/stop script for applications with log

TheHotBot Jun 2nd, 2013 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top