【发布时间】:2011-04-09 14:09:17
【问题描述】:
我想要一个代表 2010 年 9 月 6 日上午 6:00 的 cron 表达式
【问题讨论】:
标签: spring cron expression quartz-scheduler
我想要一个代表 2010 年 9 月 6 日上午 6:00 的 cron 表达式
【问题讨论】:
标签: spring cron expression quartz-scheduler
原始问题被标记为cron,因此第一部分适用于此。有关 Quartz CronTrigger 工具的更新答案,请参见下文。
大多数 crontab 不允许您指定年份,因此您可能必须将其放入脚本本身(或脚本/程序的包装器)。
你可以这样做:
if [[ $(date +%Y) != 2010 ]] ; then
exit
fi
您希望在每年 9 月 6 日早上 6 点运行的选项是
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 格式,您会看到如下内容:
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)。
【讨论】:
【讨论】:
只能在 /etc/crontab 中如下:
0 6 6 9 * root test `/bin/date +%Y` == 2010 && <your command>
【讨论】: