我有一个脚本可以每天随时运行。所以/etc/cron.daily似乎是一个简单的解决方案。
但是现在我遇到了问题,cronjob 不会运行该脚本。似乎 cronjob 不会运行任何日常工作。
所以我试着把它放到 cron.hourly 并且一切正常。但我不想每小时运行一次备份脚本。
/etc/init.d/cron start|stop 工作没有错误。
/etc/crontab 看起来像默认:
m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
Run Code Online (Sandbox Code Playgroud)
由于它不会运行,我尝试安装 anacron 但没有任何更改。
为什么它运行每小时脚本而不是每日脚本?
非常感谢你们所有人!
小智 5
可能是,您的日常脚本之一行为不端。尝试手动运行它们。我删除了 logwatch 包和 cron.daily 作业,它又工作了。
这是我的 /etc/crontab
# /etc/crontab: system-wide crontab
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
16 * * * * root cd / && run-parts --report /etc/cron.hourly
12 2 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
41 1 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
9 3 30 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
Run Code Online (Sandbox Code Playgroud)
尝试像这样每天跑步
run-parts -v --report /etc/cron.daily
Run Code Online (Sandbox Code Playgroud)
您还可以使用 --list 或 --test 获得更多输出。在我的情况下,我删除了行为不端的脚本,日常工作又开始了
我在 /etc/cron.daily 中的一个脚本也遇到了同样的问题 该脚本的名称是 backupBugzilla.sh
将脚本重命名为 backupBugzilla 后,它就起作用了。
| 归档时间: |
|
| 查看次数: |
10175 次 |
| 最近记录: |