从某个日期开始每天运行的 Cron 表达式 [英] Cron expression to run every day starting from a date
本文介绍了从某个日期开始每天运行的 Cron 表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个从 2016 年 1 月 25 日起每天中午 12 点触发的 cron 表达式.这就是我想出的:
I need a cron expression which will fire every day at 12 pm starting from jan 25 2016. This is what I came up with:
0 0 12 25/1 * ? *
但在 1 月 31 日之后,下次发射时间是 2 月 25 日.
but after jan 31, the next firing time is feb 25.
是否有用于执行此操作的 cron 表达式?如果不是,我可以使用什么?
Is there a cron expression expression for doing this? If not what can I use?
推荐答案
假设你想在 1 月 25 日之后永远运行这个进程(即 2032 年,那时服务器可能已经被替换),我会用三个表达式:
Assuming that after January 25th you want to run this process forever after (i.e. 2032, when probably the server will be already substituted), I would do it with three expressions:
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.
我希望这会有所帮助.
这篇关于从某个日期开始每天运行的 Cron 表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文