The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 08-26-2007
jbuberel jbuberel is offline
Registered User
 

Join Date: Aug 2007
Posts: 1
My simple solution...

Was to turn the date math trick shown above into a script that I named 'last-day-of-month.sh':
Code:
#!/bin/bash

TODAY=`/bin/date +%d`
TOMORROW=`/bin/date +%d -d "1 day"`

# See if tomorrow's day is less than today's
if [ $TOMORROW -lt $TODAY ]; then
        exit 0
fi

exit 1
Which can then be used within a crontab file as follows:
Code:
12 0 * * * last-day-of-month.sh && /run/my/cron/job.sh
I hope this is of some use to you...

-jason
Reply With Quote