我知道,如果我用crontab -e以下命令 编写,01 04 * * * somecommand那么它将somecommand在每个月的每一天的凌晨 4:01运行。
如果我写了会* * * * * somecommand怎样?它会somecommand每分钟运行一次吗?这种语法也适用吗?
它可以使用特殊字符串一样@reboot,@daily因为它是解释,等在这里。somecommand如果我写@daily somecommand命令会在一天中的什么时间执行?
这将每分钟运行您的命令。这是有效的语法。
以下是来自info crontab:的血腥细节:
The first five fields shall be integer patterns that specify the
following:
1. Minute [0,59]
2. Hour [0,23]
3. Day of the month [1,31]
4. Month of the year [1,12]
5. Day of the week ([0,6] with 0=Sunday)
Each of these patterns can be either an asterisk (meaning all valid
values), an element, or a list of elements separated by commas. An ele?
ment shall be either a number or two numbers separated by a hyphen
(meaning an inclusive range). The specification of days can be made by
two fields (day of the month and day of the week). If month, day of
month, and day of week are all asterisks, every day shall be matched.
If either the month or day of month is specified as an element or list,
but the day of week is an asterisk, the month and day of month fields
shall specify the days that match. If both month and day of month are
specified as an asterisk, but day of week is an element or list, then
only the specified days of the week match. Finally, if either the month
or day of month is specified as an element or list, and the day of week
is also specified as an element or list, then any day matching either
the month and day of month, or the day of week, shall be matched.
Run Code Online (Sandbox Code Playgroud)
您链接到的文章看起来不错。它为您提供了一些很好的示例,实际上它比我在此处提供的手册页摘录更容易阅读。
您应该能够使用它谈到的语法。
根据我的 crontab,@daily 在 6:25 AM 运行。
$ grep daily /etc/crontab
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
Run Code Online (Sandbox Code Playgroud)