特定日期的Cron表达式 [英] Cron expression for particular date

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

问题描述

我想要一个表示2010年9月6日上午6:00的cron表达

I want a cron expression that represents 6th September 2010 6:00 am

推荐答案

原始问题标记为 cron 所以这第一节适用于。请参阅下面的Quartz CronTrigger工具的更新答案。

Original question was tagged cron so this first section applies to that. See below for an updated answer for the Quartz CronTrigger tool.

大多数crontab不允许指定年份

Most crontabs don't let you specify the year so you'll probably have to put that in the script itself (or a wrapper around the script/program).

你可以这样做:

if [[ $(date +%Y) != 2010 ]] ; then
    exit
fi

您正在寻找的选项9月6日上午6点年是

The option you're looking for to run at 6am on September 6 every year is

0 6 6 9 * your_command_goes_here
| | | | |
| | | | +- any day of the week.
| | | +--- 9th month (September).
| | +----- 6th day of the month.
| +------- 6th hour of the day.
+--------- Top of the hour (minutes = 0).






对于Quartz CronTrigger格式,看起来像:


For the Quartz CronTrigger format, you'd be looking at something like:

0 0 6 6 9 ? 2010
| | | | | |   |
| | | | | |   +- 2010 only.
| | | | | +----- any day of the week.
| | | | +------- 9th month (September).
| | | +--------- 6th day of the month.
| | +----------- 6th hour of the day.
| +------------- Top of the hour (minutes = 0).
+--------------- Top of the minute (seconds = 0).

(详情请参阅这里)。

这篇关于特定日期的Cron表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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