#!/usr/bin/perl ########### Variables # # Put your email address here. # $Mail_Address = 'your@email.address'; ########### Files # # Specify the file where the birthdays are listed. # $Birthday_File = '/path/to/the/birthday/file'; ########### # Do not change anything below this line unless you know what you're doin' $Tmp_File = '/tmp/.crontmp'; open (NAMES, "<$Birthday_File") || die "Can't open $Birthday_File!"; open (TMP, ">$Tmp_File") || die "Can't open $Tmp_File"; print "Looking for scheduled tasks in crontab file...\n"; @Task_List = `crontab -l`; foreach $Task (@Task_List) { if($Task !~ /birthday|^#/) { print "Found non-birthday task:\n$Task","Copying to new crontab file..."; print TMP "$Task"; print "Done.\n" } } print "Reading file $Birthday_File\n"; print TMP "#birthdays\n"; while () { ($Date, $Name) = split (':', $_); ($Day, $Month) = ( $Date =~ /(\d{2})\.(\d{2})/ ); chop $Name; print "Adding $Day", ".", $Month, ". as $Name", "'s birthday..."; print TMP "0 8 ", $Day, " ", $Month, " * "; print TMP "echo Today is $Name", "\\'s birthday | mail $Mail_Address\n"; print "Done.\n" } print TMP "#birthdays_end\n"; close NAMES; close TMP; print "Updating crontab ..."; `crontab $Tmp_File`; print "Done.\n";