特定日期的Cron表达式 [英] Cron expression for particular date
问题描述
我想要一个代表2010年9月6日的cron表达6:00 am
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).
(从 here )。
这篇关于特定日期的Cron表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!