Last active
December 13, 2015 17:09
-
-
Save apsamuel/4945794 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # onscheduler: turn the java when it is off | |
| # variables: | |
| savingcell="/root/bet/schedulerLog" #log path for scheduler | |
| applog="/root/bet/application.log" | |
| pid=$(pgrep -f '.*java.*bet.*Main.*' >/dev/null) #find pid. | |
| ret=$? #log result 0 - found, 1 - not found | |
| if [ $ret -ne 0 ] | |
| then #java is off | |
| /usr/bin/nohup java -Xmx512m -cp "/root/bet/lib/*:/root/bet/src/" Main >> $applog 2>&1 #turn it on with messages redirected to log. | |
| [ $(pgrep -f '.*java.*bet.*Main.*' |wc -l) -eq 1 ] && echo "Started by script on : $(date)" >> $savingcell || echo "Something bad happend, return code: $?" >> $savingcell | |
| else #java is on | |
| echo "was already on on : $(date)" >> $savingcell | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment