
我的伺服器是 CentOS 5。系統)日誌中的「RELOAD(/etc/crontab)」或「(admin)RELOAD(cron/admin)」。
/var/log/cron 中的範例條目:
Aug 10 10:21:33 localhost crontab[31688]: (root) BEGIN EDIT (root)
Aug 10 10:21:42 localhost crontab[31688]: (root) REPLACE (root)
Aug 10 10:21:42 localhost crontab[31688]: (root) END EDIT (root)
Aug 10 10:22:01 localhost crond[2688]: (root) RELOAD (cron/root)
「service crond status」的結果:
crond (pid 1345) is running...
指令「cat /var/log/messages | grep cron」沒有給予任何資訊。
/etc/cron.allow 的內容:
admin
root
/etc/crontab 的內容:
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
* * * * * root run-parts /bin/date >> /data/date.txt
ps aux |grep cron 的結果:
root 1345 0.0 0.1 5268 1204 ? Ss 11:43 0:00 crond
管理員的 crontab 的內容:
* * * * * /bin/date >> /data/date.txt
請注意,不僅僅是管理員的 crontab 沒有運行。所有 cron 作業均未執行。
有什麼想法為什麼他們不運作嗎?
答案1
檢查是否有 /etc/cron.allow 檔案或 /etc/cron.deny 檔案導致作業被忽略。
如果 /etc/cron.allow 不存在,那麼每個人都可以執行 cron 作業。如果它在那裡但為空,我不確定是否允許任何人運行 cron 作業。
答案2
您的 crontab 中存在錯誤,請查看:
* * * * * root run-parts /bin/date >> /data/date.txt
您使用目錄 /bin/date 呼叫 run-parts - 這肯定會失敗。錯誤會傳送到 stderr 並且不會被緩存>>
答案3
/etc/cron.allow
如果指定的檔案不存在,則建立該檔案並向其中新增使用者名稱。
答案4
儘管這個問題的答案已被接受,但我想添加對我有用的內容。最好引用 URL,如果它包含查詢,那麼如果不引用所有內容,它可能無法運作。
不要忘記將包含「?、=、#、%」的 URL 放在引號中。
例子。 https://paystack.com/indexphp?docs/api/#transaction-charge-authorization&date=today 應該在像這樣的引號中“https://paystack.com/indexphp?docs/api/#transaction-charge-authorization&date=today”