People don't respond to email on a public holiday? What madness is this? Change your users...
Denis Crowdy On Thu, Nov 04, 2004 at 06:15:16PM +1100, Peter Hardy wrote: > Thought I might share my new favourite utility, wday. > > So I've got a script that's launched by cron every Monday. It emails > reminders to all users who haven't sent a progress report for the > previous week. Simple. > > Amongst other changes to be done, I was asked if this system could be > modified so, if Monday is a public holiday, reminders aren't sent until > Tuesday. Sounds simple, but I knew of no way to easily tell if a given > day was a public holiday. Debian didn't seem to have anything > pre-packaged, and I was starting to despair of evil calendar(1) > chicanery, or having to hard-code a list of exception dates in to the > script. > > Eventually found mday (http://www.nongnu.org/wday/) while googling for > alternative cron daemons that might be able to do it. Has a quiet mode, > that'll return 1 for a weekday or 0 for a weekend/public holiday, can > check today or any arbitrary date you feed it. The data for NSW seems > fairly complete (checked the output of wday -l against > http://www.industrialrelations.nsw.gov.au/holidays/ ), and the data > files are easily extensible to deal with things like uni holidays. > Perfect! > > So I've changed Monday's job to call wday before running the script, and > added a second job on Tuesday, that will only run if the previous day > was a public holiday. > > # Progress report annoyances. > # Only send on Monday if it isn't a public holiday > 30 10 * * 1 benno /usr/bin/wday -q || python /home/disy/progress_annoy.py > # Only send on Tuesday if Monday was a public holiday > 30 10 * * 2 benno /usr/bin/wday -q `/bin/date -d yesterday +%Y%m%d` && python > /home/disy/progress_annoy.py > > Brilliant! > > -- > Pete > > -- > SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ > Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html -- Department of Contemporary Music Studies Macquarie University NSW 2109 Australia, ph: +61 (0)2 9850 6787, fax: 9850 6593 http://www.ccms.mq.edu.au -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html