On Tue, Apr 06, 2010 at 12:09:01PM +0200, frantisek holop wrote:
| > Cron will just do what it's told: run whatever at "31.*. 23:59"
| 
| so i could basically do 12 lines with the correct
| last day of the month rules :]

12 ? Months come in 12 different lengths where you live ? You have
bigger issues then - base cron only knows the Gregorian calendar where
there's 3 possible lengths for months in a year.

| because for me the month ends at 23:59:59 on the last day
| of month n, and not at 00:00:00 on the first day of month n+1...

What you want can not be done with cron alone. The solution is to have
a cronjob at days 28-31 (as was already suggested) to verify if it is
indeed the last day of the month and then run the intended script. Or
have 2 entries in your crontab :

59 23 31 1,3,5,7,8,10,12 * /path/to/your/cronscript
59 23 30 4,6,9,11 * /path/to/your/cronscript

and then a third one for february that you change every leap year. Or
you could suck it up and always do the february one on the 28th :

59 23 28 2 * /path/to/your/cronscript

If you want to get really fancy, add a @yearly cronjob that changes
your crontab to suit the 2nd month of the year. It's just an s/28/29/
or s/29/28/, depending on `cal feb | grep -q 29` (make sure your box
is up and cron is running when @yearly time comes around .. maybe you
want to make this @reboot to check things).

Cron does not support 'last day of month' / 'last weekday of month'
setups.

Cheers,

Paul 'WEiRD' de Weer

-- 
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
                 http://www.weirdnet.nl/                 

Reply via email to