Crontab-e
20:59 start the script
* * * * sh/home/fzuir/xingye4crawl/endxingye4crawl.sh >/home/fzuir/xingye4crawl/xingye4_pro_kill.log 2> &1
Start:
#!/bin/bash. /home/fzuir/.profile# javaexport java_home=/usr/local/jdk1.7.0_75export jre_home= $JAVA _home/jreexport PATH= $JAVA _ Home/bin: $PATHexport classpath=.: $JAVA _home/lib: $JAVA _home/lib/tools.jar#hm=$ (Date +%h | awk ' {print $0+0} ') #echo $hm %3#tmp=$ (($hm%3)) today= ' Date +%y%m%d '; yesterday= ' date-d ' 1 days ago ' +%y%m%d ' echo yesterdayif [-x/bin/ps];then/ b In/ps-ef >/tmp/skycent$$$ 2>/tmp/skycent.err$$$ if [$?-ne 0];then exit 1 fi /bin/rm-f/tmp/sky cent.err$$ $else echo "PS not Exist" exit 1figrep "Xingye4crawlmainthread" /tmp/skycent$$$ >/dev/ Null 2>/dev/nullif [$?-ne 0];thencd/home/fzuir/xingye4crawljava-jar Xingye4crawlmainthread.jar./conf/xinye4conf . Properties >>./nohup.out 2>&1 &else echo "Xingye4crawlmainthread.jar is already runing" fi /bin/rm-f/tmp/skycent$$$
End Process:
#!/bin/bash. /home/fzuir/.profile################################################# is used to detect if there is currently a decimation program running at 0 o'clock, and if any, stop the program # Usage: Used to identify the program name of the key words to modify the actual situation, you need to add this sh crontab at 0 o ' Day running # keys= ' (ps-ef |grep keyword |grep-v grep to identify the program name) | awk ' {print $} ' ############################################### #keys = ' (Ps-ef |grep xingye4crawlmainthread |grep-v grep) | awk ' {print $} ' if [$?-eq 0];then echo ' exist this process ' for key in $keys Doecho $keykill-9 $key Doneelse echo "not exist this process" fi
"Linux" Crontab timed start sh