Cron - First Saturday of the month
Larry Wall
lwall at jpl-devvax.JPL.NASA.GOV
Thu Aug 16 09:14:42 AEST 1990
In article <1489 at hagbard.dc.luth.se> bj at dc.luth.se (B|rje Josefsson) writes:
: Slightly a side question according to the Subject:, but how to setup a
: command for execution on the LAST day of the month ONLY?
:
: I could use:
: 0 0 31 1 * command
: 0 0 28 2 * command
: 0 0 31 3 * command
: and so on
: but that will not work on leap years...
I'd suggest (surprise, surprise)
0 0 * * * perl -e '(localtime(time + 24*60*60))[3] == 1 && exec "command"'
or, more concisely
0 0 * * * perl -e 'exit+(localtime time+86400)[3]-1' && command
Larry Wall
lwall at jpl-devvax.jpl.nasa.gov
More information about the Comp.unix.wizards
mailing list