This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 months ago.
The community reviewed whether to reopen this question 3 months ago and left it closed:
Original close reason(s) were not resolved
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
正如之前的文章中所指出的,您不能指定年份字段,但是可以模仿它:
这里,
command1
将在 2020-01-01T00:00:00 上运行,command2
将每 3 年在 1 月 1 日午夜运行一次,它将在 2019、2022、2025,... 运行。command3
与command2
的作用相同,但有一年的偏移,即 2020、2023、2026,...注意:不要忘记您必须在 crontab 文件中转义字符 (
%
):As indicated in earlier posts, you cannot indicate a year field, it is, however, possible to mimic it:
Here,
command1
will run on the 2020-01-01T00:00:00,command2
will run every 3 years on the first of January at midnight, it will run so on 2019, 2022, 2025, ... .command3
does the same ascommand2
but has one year offset, i.e. 2020, 2023, 2026, ...note: don't forget that you have to escape the <percent>-character (
%
) in your crontab file:Crontab (5) 文件格式没有 YEAR 字段。您可以尝试运行一个 cron 作业 @yearly(元旦的 00:00),它使用 date(1) 查看当前年份,并将当前的 crontab 文件更新为适合新一年的文件。
Crontab (5) file format has no YEAR field. You could try running a cron job @yearly (at 00:00 on New Year's day) which looks at the current year using date(1) and updates the current crontab file to one appropriate for the new year.
标准
cron
不支持年份字段,但值得注意的是,某些实现支持带有第六个year
字段的扩展 crontab 格式,例如 nnCron。并非每个 cron 都是生而平等的。Standard
cron
doesn't support a year field, but it's worth noting that some implementations support an extended crontab format with a sixthyear
field, such as nnCron. Not every cron is created equal.这是考虑 YEAR 字段的工作..
@mart7ini
It is work for considering YEAR field..
@mart7ini