[olug] OLUG - Omaha Linux User Group: Third Thursday (fwd)

Daniel Pfile daniel at pfile.net
Tue Sep 19 21:07:10 UTC 2006


Jon Larsen wrote:
> Anybody in your group ever successfully write a cron job that only executes one week before the third thursday of each month? I'm attempting to write the cron job to post our Amateur Radio Club meetings over a digital radio. I've seen a few scripts on the web but so far none of them work. The Distro I'm writing the cron job on is MEPHIS (Debian) Distro.
>   
1 0 8-14 * * test `date +\%a` != Thu || /path/to/notify/script.whatever

Should do the trick. 1 minute after midnight, if it's the 8th through
the 14th (the second thursday should always be one of those days), check
to see if it's not thursday, otherwise run the script. It's 'backwards'
from what you'd think (date = thur && command) so that it always exits true.

FYI, I'm not really that smart, I pulled this out of Unix Power Tools
3rd edition, a book every geek needs right next to his or her's copy of
Mastering Regular Expressions.

-- Daniel



More information about the OLUG mailing list