
我有一個 Linux gentoo 系統,每天凌晨 3:10 執行一個 cronjob。但是,沒有文件包含/etc
與此特定 cronjob 相關的任何信息,並且結果crontab -l
是
# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
MAILTO=""
0 * * * * rm -f /var/spool/cron/lastrun/cron.hourly
1 3 * * * rm -f /var/spool/cron/lastrun/cron.daily
15 4 * * 6 rm -f /var/spool/cron/lastrun/cron.weekly
30 5 1 * * rm -f /var/spool/cron/lastrun/cron.monthly
*/10 * * * * test -x /usr/sbin/run-crons && /usr/sbin/run-crons
目錄/etc/cron.daily
可能包含有問題的作業,但時間是在 3:01!這是為什麼?實際的 cronjobn 是否存放在其他地方? gentoo需要9分鐘才能實現執行一項工作嗎?
附加資訊:
- 我在 13:20 有一個不同的 crontab 作業(在 cron.d 中),它在每天 13:20 準確執行。
答案1
檢查它是否不是來自其他用戶:
getent passwd | while read r; do sudo -u $(echo $r | cut -d':' -f1) crontab -l; done
答案2
crontab -l
僅列出呼叫使用者的每使用者 crontab。還有一個系統 crontab,它只能由 root 編輯,但可以以任何使用者身分執行作業。系統 crontab 位於該檔案中/etc/crontab
,其他作業則位於該目錄中的檔案中/etc/cron.d
。
目錄/etc/cron.daily
、/etc/cron.weekly
和/etc/cron.monthly
不是由 cron 內建的,而是由 中列出的作業遍歷/etc/crontab
。