View previous topic :: View next topic |
Author |
Message |
msalerno Veteran
Joined: 17 Dec 2002 Posts: 1338 Location: Sweating in South Florida
|
Posted: Thu Sep 23, 2010 8:05 pm Post subject: cronjob - Second tuesday of the month? |
|
|
I'm trying to see if this is possible, but I don't see much in crontab(5) or online. Is this possible without additional coding? |
|
Back to top |
|
|
madchaz l33t
Joined: 01 Jul 2003 Posts: 993 Location: Quebec, Canada
|
Posted: Thu Sep 23, 2010 8:43 pm Post subject: |
|
|
afraid not. The way cron works is you can specify the following.
Minute, hour, day of month, month, day of week.
So you could specify the second day of the week, but not the second day of the second week. _________________ Someone asked me once if I suffered from mental illness. I told him I enjoyed every second of it.
www.madchaz.com A small candle of a website. As my lab specs on it. |
|
Back to top |
|
|
toralf Developer
Joined: 01 Feb 2004 Posts: 3925 Location: Hamburg
|
Posted: Thu Sep 23, 2010 9:17 pm Post subject: |
|
|
BTW I'm wondering whether "2/2" would gives the 2nd (but the 4th too) Tuesday of a month. |
|
Back to top |
|
|
avx Advocate
Joined: 21 Jun 2004 Posts: 2152
|
|
Back to top |
|
|
javeree Guru
Joined: 29 Jan 2006 Posts: 453
|
Posted: Fri Sep 24, 2010 7:58 am Post subject: |
|
|
second tuesday of the second week should always fall somewhere between the 7th and the 13th =>
#Minute, hour, day of month, month, day of week.
minute hour 7,8,9,10,11,12,13 month 2 |
|
Back to top |
|
|
toralf Developer
Joined: 01 Feb 2004 Posts: 3925 Location: Hamburg
|
Posted: Fri Sep 24, 2010 8:03 am Post subject: |
|
|
javeree wrote: | second tuesday of the second week should always fall somewhere between the 7th and the 13th =>
#Minute, hour, day of month, month, day of week.
minute hour 7,8,9,10,11,12,13 month 2 | Doesn't this mean : "run from 7th till 13th _and_ every Tuesday" ?
BTW I contacted the author of vixie-cron. He wrote: Quote: | there is no posix cron syntax for second tuesday, but if you have a proposal and a patch (including code and documentation) i'll look at it. |
|
|
Back to top |
|
|
javeree Guru
Joined: 29 Jan 2006 Posts: 453
|
Posted: Fri Sep 24, 2010 12:47 pm Post subject: |
|
|
I understand this means:
run whenever the date is one of 7 to 13 AND it is a tuesday (AND, not OR).
If you want or, you need to have different lines. |
|
Back to top |
|
|
toralf Developer
Joined: 01 Feb 2004 Posts: 3925 Location: Hamburg
|
Posted: Fri Sep 24, 2010 2:05 pm Post subject: |
|
|
please ... read the man page : Code: | Commands are executed by cron(8) when the minute, hour, and
month of year fields match the current time, and when at least one of the two day fields (day of
month, or day of week) match the current time (see ``Note'' below). |
|
|
Back to top |
|
|
wthrowe Tux's lil' helper
Joined: 19 Aug 2009 Posts: 141
|
Posted: Fri Sep 24, 2010 2:06 pm Post subject: |
|
|
Unfortunately, toralf is right. Seems like the other behavior would be more useful.
crontab(5) wrote: | Note: The day of a command's execution can be specified by two fields -- day of month, and day of week. If both fields are restricted (ie, aren't *), the command will be run when either field matches the current time. For example, ``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday. |
|
|
Back to top |
|
|
msalerno Veteran
Joined: 17 Dec 2002 Posts: 1338 Location: Sweating in South Florida
|
Posted: Fri Sep 24, 2010 2:49 pm Post subject: |
|
|
So to sum it all up, it cannot do it. |
|
Back to top |
|
|
wthrowe Tux's lil' helper
Joined: 19 Aug 2009 Posts: 141
|
Posted: Fri Sep 24, 2010 4:02 pm Post subject: |
|
|
msalerno wrote: | So to sum it all up, it cannot do it. |
cron can't do it alone, but you could easily put Code: | [ `date +%u` = 2 ] && foo | as a command in the crontab to run every day from the 8th to the 14th of each month in order to get foo run on the second Tuesday. |
|
Back to top |
|
|
|