通過shell創建計劃任務

tempfile=/tmp/tempfile.cron

 

# 將crontab原有的任務copy到tempfile中

crontab -l > $tempfile

 

# 把將要執行的任務追加到上一步得到的文件中

echo "0 0 * * *  /clear.sh 1>/dev/null" >> $tempfile

 

# 將上一步得到的文件中的所有任務導入crontab中

crontab $tempfile

 

service crond restart

rm -f $tempfile

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章