shell脚本内容:
重启crond服务
tempfile=/tmp/tempfile.cron
# 将crontab原有的任务copy到tempfile中
crontab -l > $tempfile
# 把将要执行的任务追加到上一步得到的文件中
echo "0 0 * * * /clear.sh 1>/dev/null" >> $tempfile
# 将上一步得到的文件中的所有任务导入crontab中
crontab $tempfile
rm -f $tempfile
重启crond服务
sudo service crond restart