?????????????
????д???????????????????????????????????linux??crontab????????????????????????????????????????????????????????????????????????κ????顣??????????????crontab?????к???shell?????????е???????????
????????????
??????????????/home/watch.sh???????
????#!/bin/sh
????shell_log_file=/home/start.log
????pid_count=`pidof video_checkup | wc -w`
????path=$(cd "$(dirname "$0")"; pwd)
????run_command="${path}/video_checkup"
????config_path="${path}/config.json"
????if [ $pid_count -eq 0  ]; then
????echo `date +%Y-%m-%d_%H:%M:%S`" run $run_command $config_path" >> $shell_log_file
????$run_command $config_path
????else
????echo `date +%Y-%m-%d_%H:%M:%S`" video_checkup already running" >> $shell_log_file
????fi
??????shell????????crontab -e ??????????????
????*/1 * * * *  /home/watch.sh >/dev/null 2>&1
????????y?????????????Σ???????????????????video_checkup?粻?????????????????????????????????video_checkup???????????????????????????Ρ?
???????????
?????????????????? if [ $pid_count -eq 0  ]; then ??ζ?????????video_checkup???????? $pid_count -eq 0 ????ж???ζ???true???? $pid_count ???????log????з???????0 ??
????????video_checkup?????????е????????????0?????watch.sh??shell?????????????????????????($pid_count?????????????е?video_checkup??????????)??????google???????crontab???????????н??watch.sh????????????????ssh?????shell????????watch.sh???????????????????????watch.sh?м???????????
????echo `export` >> $shell_log_file  ???????crontab?????watch.sh???????ssh?????shell????????watch.sh??????export???????????
??????crontab?????watch.sh?????log??????????export?????PATH?????? export PATH="/usr/bin:/bin"
??????ssh?????shell?????????watch.sh???log??????????export????е?PATH?????? PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" ???????????????PATH?????? pid_count=`pidof video_checkup | wc -w` ??е???????????
??????????????????????pidof????????????????  ??ssh??shell????????У?
????[root@172-28-246-152 video_checkup]# which pidof
????/sbin/pidof
????????pidof???????? /sbin/???£?????crontab???е?????? PATH="/usr/bin:/bin" ???и??????pidof????????????crontab????? watch.sh?е? pid_count=`pidof video_checkup | wc -w` ???????????????????????б??棬????pid_count?????л????????????pidof????????????????????????????
????????ssh??shell?й?????????????pidof·????????£?
????[root@172-28-246-152 video_checkup]# pid_count=`/xx/pidof video_checkup | wc -w`
????-bash: /xx/pidof: No such file or directory
????????????No such file or directory???????????????pid_count??????????? ??????£?
????[root@172-28-246-152 video_checkup]# pid_count=`/xx/pidof video_checkup | wc -w` && echo $pid_count
????-bash: /xx/pidof: No such file or directory
????0
????????????????: ????crontab???????У?????pidof???????????????????????????????????????????????????????????????? wc -w  ???????????????????wc -w???????κ?????????????е?????? 0 ???????pid_count????? 0 ???
??????????
??????ssh???????shell?????е?PATH?????watch.sh????м????????????????е????????????? pidof ????ó?????????? (???????watch.sh????????????? PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" ????)
???????С?????????????С?????????????????ü??????????????ù????л????к????