Phi*_*lds 19
即使特雷弗是正确的,我也在这里给出一个替代答案。
cron@weekly
关键字与他提到的完全一样。但是,大多数发行版都使用run-parts
自己的计划 crontab 文件(每小时、每天、每周和每月),这些文件不使用 cron 的关键字。
例如,Ubuntu 有一个/etc/cron.weekly
包含每个 cronjob 的单独文件。
这通常定义在 /etc/crontab
Ubuntu 的 karmic 9.10 版本包含以下内容 /etc/crontab
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)
所以 Ubuntu 中的每周 crontab 在周日早上 6.47 运行
注意:在查找 crontab 实现的联机帮助页时,您希望使用man 5 crontab
而不仅仅是man crontab
. 后者只会为您提供 crontab 命令的语法。前者为您提供 crontab 实现细节。
答案就在 crontab 本身的联机帮助页中 ( man 5 crontab
):
支持这些特殊时间规范“昵称”,它们替换 5 个初始时间和日期字段,并以“@”字符为前缀:
Run Code Online (Sandbox Code Playgroud)@reboot : Run once after reboot. @yearly : Run once a year, ie. "0 0 1 1 *". @annually : Run once a year, ie. "0 0 1 1 *". @monthly : Run once a month, ie. "0 0 1 * *". @weekly : Run once a week, ie. "0 0 * * 0". @daily : Run once a day, ie. "0 0 * * *". @hourly : Run once an hour, ie. "0 * * * *".
所以,现在是0 0 * * 0
,周日的午夜。
(即工作日 0(即星期日)的 0 小时的 0 分钟。)
归档时间: |
|
查看次数: |
24280 次 |
最近记录: |