The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 10-13-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Unfortunately cron isn't very flexible in that respect. Does your script need to run exactly every 15 days, or could you just run it on the 1st and 16th of every month, i.e. approximately every 15 days?

Otherwise you might have to just run the job every day, and add some logic so that it exits without doing anything if the current number of days since Jan 1, 1970 is not evenly divisible by 15:

Code:
days_since_epoch=$(perl -e 'print int(time/86400)"\n";')

if [[ "$(( $days_since_epoch % 15 ))" -ne 0 ]]
then
    exit
else
    # do your stuff
fi

Last edited by Annihilannic; 10-13-2008 at 02:19 AM.. Reason: Removed duplicate calculation of modulus.