UnixCronRunLastDayOfMonth


This script checks if it's the last day of the month, or the 15th, and executes only under those circumstances. Then, I put it in the crontab to run every day.

 

#!/usr/bin/bash 
TOMORROW=`/usr/bin/date -d tomorrow +%d`; 
 
if [ ! ( "$TOMORROW" == "01" -o "$TOMORROW" == "16" ) ]; then 
exit 
fi 
 
# Instructions to execute 

-Attribution

 

And in Perl:

 

 

#!/usr/local/bin/perl
use strict;

my ($mday,$wday,$j);
($j,$j,$j,$mday,$j,$j,$wday,$j,$j) = localtime(time);

#Only run the first saturday of the month
exit unless($wday == 6 && $mday <= 7);

# Instructions to execute