Cronjob
Paul Chvostek
paul+fbsd at it.ca
Mon Jun 8 14:36:16 UTC 2009
Hi Jos,
On Mon, Jun 08, 2009 at 02:55:56PM +0200, Jos Chrispijn wrote:
>
> I would like to execute a script on every last day of the month in my
> crontab.
> Can someone tell me how I should solve that as it doesn't know which
> month day is the last day of the month?
> Solving this in the script to be executed is no option.
The only solutions I see are the three-cronjob approach:
0 1 31 1,3,5,7,8,10,12 * /path/to/script
0 1 28 2 * /path/to/script
0 1 30 4,6,9,11 * /path/to/script
Alternately, you could do this with a single cronjob by putting a little
scripting intelligence into the crontab itself:
0 1 28-31 * * test `date -v+1d '+%d'` -eq 1 && /path/to/script
That may be your easiest option. The script only gets run on the
correct dates, but the cron job still gets run more frequently.
p
--
Paul Chvostek <paul at it.ca>
it.canada http://www.it.ca/
More information about the freebsd-questions
mailing list