Run shell script alternate week per month

Hi All,

Requirement :-
I have shell script in kern shell ,have to run alternate week per month
example-today's date is 27 Mar 2013 and my script will run today then for the next time when it will run it should check 1st what was the last run date(27 Mar 2013) if it is matched 15days from current date then run else sent a mail with waning mgs.

i have a AWK command it is checking only within a month

date +%Y:%m:%d|awk -vFS=":" -vOFS=":" '{$3=$3-3;print}'

suppose i am checking 20days from current date it is give some negative value
ex-2013:03:-8

Please give some advice me so i can move forward.

Thank you All.

Regards,
Krupa

you can perform epoch arithmetic

1 day = 86400 secs
15 days = 1296000 secs

today's date

$ date
Fri Mar 22 06:18:17 EDT 2013

script to calculate date after 15 days

today=`date +%s`;let after_15=today+1296000; date -d "@${after_15}"

o/p

Sat Apr  6 06:16:39 EDT 2013
1 Like

Hi,

I am getting below errors

`date +%s`;let after_15=today+1296000; date -d "@${after_15}"
date: bad format character - s
ksh: after_15=today+1296000: bad number
date: illegal option -- d
Usage: date [-u] [+format]
       date [-u] [mmddhhmm[[cc]yy]]
       date [-a [-]sss.fff]

this is Working in Bash shell but not in ksh
Please provide me alternate solutions

Thanks,
Krupa