[sclug] Happy sysadmin day
ed
ed at s5h.net
Fri Jul 27 20:45:10 UTC 2007
On Fri, 27 Jul 2007 02:45:37 +0100
John Stumbles <john at stumbles.org.uk> wrote:
> (for those who haven't seen this before)
>
> http://eclectech.co.uk/sysadminday.php
:-( Missed it again, I normally try to send an email to everyone at
work for occasions like this.
I don't think it's possible to put a clause into a crontab entry that
can decide if today is the last occurrence of that weekday for the
month, so here's a short perl snippet, if you're like me you will have
forgotten about sysadmin day for a series of years.
It prints a short message and cron should capture and email this to the
user who owns the crontab.
My crontab entry for this is as follows:
40 8 * 7 fri /usr/bin/perl /home/ed/code/perl/last_friday.pl
And the script looks like this. Maybe next year I can mail it out on
time!
#!/usr/bin/perl
use strict;
use warnings;
sub is_today_the_last_friday_of_month {
my $d = time();
my @t = localtime($d);
if( $t[6] != 5 ) {
return(0);
}
my @next_week = localtime( $d + ( 7 * 24 * 60 * 60 ) );
if( $next_week[4] eq $t[4] ) {
return(0);
}
return(1);
}
if( is_today_the_last_friday_of_month() ) {
print( STDERR "Sysadmin day!!\n\n" );
}
--
The OC48 to the trailer park is bouncing like a rubber biscut because
of Bernard Shifman threatening to sue. GST is ordering a pizza.
:: http://www.s5h.net/ :: http://www.s5h.net/gpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.sclug.org.uk/pipermail/sclug/attachments/20070727/a2086c99/attachment.bin
More information about the Sclug
mailing list