"Linux" Crontab timed start sh

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.