根据crontab大师,许多功能(例如 @reboot、@daily、@annually 等)都不是标准的。有什么方法可以知道我的系统(Kubuntu 21.04)上实现的是什么吗?我试过手册页,但没有结果。
谢谢
答案1
支持的用于时间规范的“特殊字符串”列如下man 5 crontab
:
Instead of the first five fields, one of eight special strings may ap‐ pear: 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 * * * *". Please note that startup, as far as @reboot is concerned, is the time when the cron(8) daemon startup. In particular, it may be before some system daemons, or other facilities, were startup. This is due to the boot order sequence of the machine.
如果您不相信您的系统的文档,那么您可以下载源代码(例如apt-get source cron
)并检查entry.c
文件:
cron-3.0pl1$ grep '!strcmp' entry.c
if (!strcmp("reboot", cmd)) {
} else if (!strcmp("yearly", cmd) || !strcmp("annually", cmd)){
} else if (!strcmp("monthly", cmd)) {
} else if (!strcmp("weekly", cmd)) {
} else if (!strcmp("daily", cmd) || !strcmp("midnight", cmd)) {
} else if (!strcmp("hourly", cmd)) {