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

Jay Hannah jay at jays.net
Wed Sep 20 13:13:22 UTC 2006


Date: Sun, 17 Sep 2006 20:42:41 -0500
From: Stan Coleman <stan at srcproductions.com>
> 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.

Perhaps run a Perl script every Thursday (or every day) and have perl  
execute your script.whatever if it happens to be the 3rd Thursday?

-----
#!/usr/bin/perl

use strict;
use Date::Calc qw( Today Nth_Weekday_of_Month_Year );

my ($y, $m, $d) = Today();
my @third_thursday = Nth_Weekday_of_Month_Year($y, $m, 4, 3);
if ($third_thursday[2] == $d) {
    # Today is the 3rd Thursday of this month. Run!
    exec '/path/to/notify/script.whatever';
} else {
    # Today is not the 3rd Thursday of this month. Do nothing.
}
-----

http://search.cpan.org/~stbey/Date-Calc-5.4/Calc.pod

HTH,

j
Omaha Perl Mongers: http://omaha.pm.org




More information about the OLUG mailing list