2011-05-11 208 views
-1

crontab中的備份腳本未執行,crond日誌沒有顯示執行作業的任何內容。我編輯了/ etc/crontab,然後重新啓動了crond。縹緲。怎麼了?cron作業未執行

 
SHELL=/bin/bash 
PATH=/sbin:/bin:/usr/sbin:/usr/bin 
MAILTO=root 
HOME=/ 

# run-parts 
01 * * * * root run-parts /etc/cron.hourly 
02 4 * * * root run-parts /etc/cron.daily 
22 4 * * 0 root run-parts /etc/cron.weekly 
42 4 1 * * root run-parts /etc/cron.monthly 

#backup home dir w/ important scripts 
00 02 * * * root /home/backup.sh 
+0

什麼操作系統?你怎麼知道crond在運行?它是否出現在ps輸出中?/home/backup.sh是正確的文件名嗎?根郵箱中有什麼?什麼是運行部件?從cron調用程序時始終使用絕對路徑名。像'/ bin/date>/tmp/date.cron'這樣的cronjob有效嗎? – Jens 2011-08-26 16:16:00

回答

0

試圖通過這種替換00 02 * * * root /home/backup.sh00 02 * * * ./home/backup.sh

0
# run-parts 
@hourly /etc/cron.hourly 
@daily /etc/cron.daily 
@weekly /etc/cron.weekly 
@monthly /etc/cron.monthly 

#backup 
@midnight /home/$username/backup.sh 

如果運行這個的cron爲根,則家庭會像/root/scripts/backup.sh

string   meaning 
------   ------- 
@reboot  Run once, at startup. 
@yearly  Run once a year, "0 0 1 1 *". 
@annually  (same as @yearly) 
@monthly  Run once a month, "0 0 1 * *". 
@weekly  Run once a week, "0 0 * * 0". 
@daily   Run once a day, "0 0 * * *". 
@midnight  (same as @daily) 
@hourly  Run once an hour, "0 * * * *".