Cron表达式从日期开始每天运行 [英] Cron expression to run every day starting from a date

查看:1269
本文介绍了Cron表达式从日期开始每天运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个cron表达式,该表达式将从2016年1月25日起每天下午12点触发。这是我想到的:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆