从某个日期开始每天运行的 Cron 表达式

Hei*_*erg 5 cron quartz-scheduler cronexpression

我需要一个 cron 表达式,从 2016 年 1 月 25 日开始,它每天中午 12 点都会触发。这就是我的想法:

0 0 12 25/1 * ? *
Run Code Online (Sandbox Code Playgroud)

但1月31日之后,下一次发射时间是2月25日。

有没有一个 cron 表达式可以做到这一点?如果没有我可以用什么?

Jor*_*res 4

假设 1 月 25 日之后您想要永远运行此进程(即 2032 年,那时服务器可能已经被替换),我将使用三个表达式来执行此操作:

0 0 12 25-31 1 * 2016  command # Will run the last days of Jan 2016 after the 25th
0 0 12 * 2-12 * 2016   command # Will run the rest of the months of 2016
0 0 12 * * * 2017-2032 command # will run for every day of years 2017 and after.
Run Code Online (Sandbox Code Playgroud)

我希望这有帮助。