添加指定crontab
ct_list="/tmp/crontab.list" crontab -l > $ct_list cp $ct_list $ct_list.bak tagent_ct=`grep -c "fatal_monitor.sh" $ct_list` if [ $tagent_ct -eq 0 ];then (crontab -l 2>/dev/null; echo "* * * * * sh /data/home/user00/tools/fantasy-alarm.sh") | crontab - fi
删除指定crontab
job="* * * * * sh /data/home/user00/tools/fantasy-alarm.sh" is_exists=`crontab -l|grep "fantasy-alarm"|wc -l` if [ $is_exists -ge 1 ];then ( crontab -l | grep -v "$job" ) | crontab - crontab -l fi
标签:grep,list,crontab,fantasy,sh,操作,ct From: https://www.cnblogs.com/skyflask/p/16725221.html