I want a cron expression that represents 6th September 2010 6:00 am
+2
A:
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).
paxdiablo
2010-09-08 07:23:52
can please explain with each field
NewBeee_Java
2010-09-08 07:29:04
There ya go, @NewBie.
paxdiablo
2010-09-08 07:30:05
from http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html we also need to mention hour ,minute and second
NewBeee_Java
2010-09-08 07:31:33
@NewBie, CronTrigger is not cron. I've never seen a cron that allows either seconds or years to be specified. Quartz may allow that, I wouldn't know since I've never used it but, if your question is about Quartz/CronTrigger rather than the real cron, you should retag it so.
paxdiablo
2010-09-08 07:42:03
@pax did that..
NewBeee_Java
2010-09-08 07:43:53
second field is still missing pax
NewBeee_Java
2010-09-08 07:51:34
Okay, @NewBie, updated as per your edits.
paxdiablo
2010-09-08 07:51:42
you need to edit your answer second field is not labled properly. thanks to @org.
NewBeee_Java
2010-09-08 08:40:12
@NewBie, I think it is, but it may be a cultural thing. Top of the hour, at least here in the Great Southern Land, means something-o'clock (i.e., minutes = 0). Updated description to clarify.
paxdiablo
2010-09-08 09:17:48
ok Pax I misunderstood :)
NewBeee_Java
2010-09-08 09:59:01
+1
A:
0 0 6 6 9 ? 2010
second minute hour[24 hr format] day-of-month month day-of-week year[optional]
org.life.java
2010-09-08 08:37:27