Friday, December 30, 2011

CronTrigger Tutorial

SkyHi @ Friday, December 30, 2011
Original question was tagged cron so this first section applies to that. See below for an updated answer for the Quartz CronTrigger tool.

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).
You can do this with something like:
if [[ $(date +%Y) != 2010 ]] ; then
    exit
fi
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).


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).
(details garnered from here).




REFERENCES
http://stackoverflow.com/questions/3665441/cron-expression-for-particular-date
http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger