不清楚来自 crontab 的联机帮助页。字段之间是否允许额外的空白?例如,如果我有这个:
1 7 * * * /scripts/foo
5 17 * * 6 /script/bar
31 6 * * 0 /scripts/bofh
Run Code Online (Sandbox Code Playgroud)
像这样很好地重新格式化它是否安全:
1 7 * * * /scripts/foo
5 17 * * 6 /script/bar
31 6 * * 0 /scripts/bofh
Run Code Online (Sandbox Code Playgroud)
?
Ant*_*hon 26
是的,允许额外的空间,您可以很好地排列您的字段以提高可读性。从man 5 crontab
Blank lines and leading spaces and tabs are ignored.
Run Code Online (Sandbox Code Playgroud)
和
An environment setting is of the form,
name = value
where the spaces around the equal-sign (=) are optional, and any sub?
sequent non-leading spaces in value will be part of the value assigned
to name.
Run Code Online (Sandbox Code Playgroud)
对于字段本身,手册页说:
The fields may be separated by spaces or tabs.
Run Code Online (Sandbox Code Playgroud)
这应该很清楚:允许多个空格。
eyo*_*100 20
是 允许使用额外的空格。考虑:
#Mins Hours Days Months Day of the week
10 3 1 1 * /bin/echo "I don't really like cron"
30 16 * 1,2 * /bin/echo "I like cron a little"
* * * 1-12/2 * /bin/echo "I really like cron"
Run Code Online (Sandbox Code Playgroud)
我总是添加列标题,因为我懒得记住所有数字的顺序,但这是 crontab 生成的内容:
这个 crontab 应该每隔一个月(每个偶数月)的每一天每一小时的每一分钟回应“我真的很喜欢 cron”。显然,只有当您真的喜欢 cron 时才会这样做。crontab 还会在 1 月和 2 月的每天 16:30 回声“我有点喜欢 cron”。它还会在 1 月 1 日的 3:10 回应“我真的不喜欢 cron”。
归档时间: |
|
查看次数: |
20167 次 |
最近记录: |