How to get fridays date of each week


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to get fridays date of each week
# 1  
Old 04-26-2011
Question How to get fridays date of each week

Hi,

I have a requirement, to pass Fridays date to my job. Here im using ESP scheduler to run the job, but ESP can only pass the date on which it is running. It passes saturday date if it runs on sturday. I can schedule my job on friday so that it can pass firday date, but if for some reason job run on saturday or sunday my job will give unproper results. So could you guys plz help me in finding fridays date in Unix wrapper script itself.
Thanks in advance for all.

Regards
Suman
# 2  
Old 04-26-2011
Code:
#!/bin/ksh

if [ "$(date +%u)" -eq 5 ]; then
   echo 'Must be Friday - skipping'
   exit 1
fi

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 04-26-2011
i didn't get you

---------- Post updated at 01:13 PM ---------- Previous update was at 01:11 PM ----------

Quote:
Originally Posted by vgersh99
Code:
#!/bin/ksh
 
if [ "$(date +%u)" -eq 5 ]; then
   echo 'Must be Friday - skipping'
   exit 1
fi


Thanks for quick reply.

what exactly it will give me...?
Let me make my question clear.
My job need to run on weekly basis on every friday.
If for some reason job runs on saturday or sunday or monday or anyday, then also i need previous friday date in the wrapper script. I would like to hold that date in a varibale (parameter). Please explain me how you above function would work for my requiremnt.

Regards
suman
# 4  
Old 04-26-2011
What OS? Post the output of uname -a.
This User Gave Thanks to Perderabo For This Post:
# 5  
Old 04-26-2011
SunOS $servername 5.9 Generic_118558-39 sun4u sparc SUNW,Sun-Fire-15000
# 6  
Old 04-26-2011
sorry, I misunderstood what you'd wanted.
Code:
#!/bin/ksh

if [ "$(date +%u)" -ne 5 ]; then
   echo 'Must be Friday - skipping'
   exit 1
fi

The above when put in a script will exit the script if the script gets run on any day other than Friday (the 5-th day of the week).
I believe this solves one part your question....
This User Gave Thanks to vgersh99 For This Post:
# 7  
Old 04-26-2011
Ya.., that's right. But my requirement is not to skip the job if it is saturday or sunday.
My req is to to run the job with Fridays date, even it's running on saturday or sunday.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Splitting week start date and end date based on custom period start dates

Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below. Could you please help out to achieve solution through shell script.. File content: ... (2 Replies)
Discussion started by: nani2019
2 Replies

2. Shell Programming and Scripting

Find week of the year for given date using date command inside awk

Hi all, Need an urgent help on the below scenario. script: awk -F"," 'BEGIN { #some variable assignment} { #some calculation and put values in array} END { year=#getting it from array and assume this will be 2014 month=#getting it from array and this will be 05 date=#... (7 Replies)
Discussion started by: vijaidhas
7 Replies

3. Shell Programming and Scripting

Extract week start,end date from given date in PERL

Hi All, what i want to do in perl is i should give the date at run time .Suppose date given is 23/12/2011(mm/dd/yyyy) the perl script shold find week start date, week end date, previous week start date,end date,next week start date, end date. In this case week start date will be-:12/19/2011... (2 Replies)
Discussion started by: parthmittal2007
2 Replies

4. Shell Programming and Scripting

Know the number of the week for a date

Hi, I tried to find the solution on the forum without success. datecalc from Perderabo doesn't solve my problem. I would like to know how to do the same thing that date +%U but for a specific date. For example: 2011 08 27 => 39 Thinks a lot (8 Replies)
Discussion started by: Castelior
8 Replies

5. Shell Programming and Scripting

Date One Week Ago From Given Date, Not From Current Date

Hi all, I've used various scripts in the past to work out the date last week from the current date, however I now have a need to work out the date 1 week from a given date. So for example, if I have a date of the 23rd July 2010, I would like a script that can work out that one week back was... (4 Replies)
Discussion started by: Donkey25
4 Replies

6. Shell Programming and Scripting

how to obtain date and day of the week from `date` command

Hi, does anybody know how to format `date` command correctly to return the day of the week? Thanks -A I work in ksh.... (1 Reply)
Discussion started by: aoussenko
1 Replies

7. Shell Programming and Scripting

need help to get last week date

Hi, How to get last week date ? Normally i use this command : But somehow this not working in SunOS And i try use this : But in SunOS only working only get last 6 days Cheers, (1 Reply)
Discussion started by: justbow
1 Replies
Login or Register to Ask a Question