Run shell script alternate week per month | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Run shell script alternate week per month

Shell Programming and Scripting


Tags
run shell script alternate week

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-22-2013
krupasindhu18 krupasindhu18 is offline
Registered User
 
Join Date: Sep 2011
Last Activity: 24 September 2014, 9:29 AM EDT
Location: Chennai,India
Posts: 76
Thanks: 13
Thanked 1 Time in 1 Post
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
Code:
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

Last edited by vbe; 03-22-2013 at 07:12 AM..
Sponsored Links
    #2  
Old 03-22-2013
sam05121988 sam05121988 is offline
Registered User
 
Join Date: Jul 2011
Last Activity: 28 October 2014, 9:02 AM EDT
Location: Pune, India
Posts: 77
Thanks: 12
Thanked 6 Times in 6 Posts
RedHat use epoch arithmetic

you can perform epoch arithmetic


Code:
1 day = 86400 secs
15 days = 1296000 secs


today's date

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

script to calculate date after 15 days


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

o/p

Code:
Sat Apr  6 06:16:39 EDT 2013

The Following User Says Thank You to sam05121988 For This Useful Post:
panyam (03-22-2013)
Sponsored Links
    #3  
Old 03-26-2013
krupasindhu18 krupasindhu18 is offline
Registered User
 
Join Date: Sep 2011
Last Activity: 24 September 2014, 9:29 AM EDT
Location: Chennai,India
Posts: 76
Thanks: 13
Thanked 1 Time in 1 Post
Hi,

I am getting below errors


Code:
`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

Last edited by Franklin52; 03-26-2013 at 06:40 AM.. Reason: Please use code tags for data and code samples
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Finding the nth Particular Week in a Month shell script itkamaraj Answers to Frequently Asked Questions 1 12-05-2012 04:29 PM
run the script on every 31st of month..... aks_1902 Shell Programming and Scripting 3 10-24-2011 06:29 AM
run the script for last day of the month aks_1902 Shell Programming and Scripting 4 10-20-2011 03:43 AM
Cron job scheduling on the alternate day of the week kumarmani Solaris 7 09-30-2008 07:10 AM
Execute a script on 4 week of the month tbdo88 Shell Programming and Scripting 1 09-30-2006 01:08 PM



All times are GMT -4. The time now is 09:48 AM.