need help in crontab

I have a script called nav1.sh. How to crontab this script so that it runs every 15 days. Below the Crontab option availaible in my Unix AIx version.Let's say for example if my script rans on 13th Oct then it again after 15 days it should ran i.e on 28th Oct and so on .

Min(0-59) Hour(0-23) DayofMonth(1-31) Month(1-12) DayofWeek(0-6, Sun=0)

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:

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

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

yes script has to run every 15days. if it rans today i.e. 13th oct, next would be on 28th oct and again 0n 13th nov.

I have below given the script details,can u tell me how to implement this date logic inside my script

-------------------------------------------------------------------------

#!/bin/ksh

cd /var/preserve

count=0
count=`ls -ltr | grep ^- | grep 'pipe' | wc -l`

if [ $count -eq 0 ]
then
echo "0 Files are owned by pipe"
else
echo "total files owned by pipe is $count"
ls -ltr | grep 'pipe' | xargs rm -f -
echo "All pipe files are deleted"
fi
-------------------------------------------------------------------------

i know of a command that will give the date after 15days, but not getting the logic to implement it inside the script

TZ=`date +%Z`-360 ;a=`date +%Y-%m-%d`--------> 2008-10-28

Just change the beginning like this. Today is 14165 days since the epoch, and 14165 % 15 = 5. That means this script will run today, and in 15 days time, 30 days, 45, etc.

#!/bin/ksh

days_since_epoch=$(perl -e 'print int(time/86400);')

if [[ "$(( $days_since_epoch % 15 ))" -ne 5 ]]
then
    exit
fi

...

but u missed the else part shall it be like this

#!/bin/ksh

days_since_epoch=$(perl -e 'print int(time/86400);')

if [[ "$(( $days_since_epoch % 15 ))" -ne 5 ]]
then
exit
else
my script
fi

Think about it... there's no real need for the else part... if it's not the day you want, it will exit... if it *is* the day you want, the script will just continue on and execute the rest of your code.

You could put it in an else clause if you wish, but the result is the same.

thanks a lot. got the logic and again thank you so much