[Eug-lug] crontab - last day of month
Alan
euglug at thebucks.net
Mon Nov 20 12:02:14 PST 2006
Matthew Jarvis wrote:
> It seems I stepped in some doodoo trying to accomplish this - hard to
> believe this is so hard...
>
> How do I tell a cron job to run on the last day of the month?
>
> i.e. Feb 28 (or 29 whatever), Apr 30, Mar 31.... I'm being so explicit
> because another group I posted this to just didn't grasp that I wanted
> the last day, rather than specifically telling it the 28th or something...
>
> One suggestion was to run it for 28, 29, 30, 31 and then determine some
> other way if it's really the last day of the month...
>
> Some say it can't be done... are they right?
>
>
The key is not figuring out if the current day is the last day, but
figuring out if the next day is the _first_ day.
Shamelessly stolen from somewhere (don't ask me, I don't remember where):
#!/bin/sh
if test `TZ=PST-24 date +%d` = 1; then
echo 1st
fi
-ajb
More information about the EUGLUG
mailing list