Running Script via Crontab on 2nd Working day each month


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Running Script via Crontab on 2nd Working day each month
# 1  
Old 11-08-2011
Running Script via Crontab on 2nd Working day each month

Hello Guys,

I have a questions regarding running a shell script every second working day each month.
I have no clue how solve this problem Smilie.
Important is that it has to be the second working (Mo-Fr).
Example: If 1st and 2nd Days of month are Sat and Sun the script must run on 4th day of month (2n working day) which is Thuesday.

Thanks for your help!

Kind Regards
David
# 2  
Old 11-08-2011
Wait a minute...
your exemple makes monday the 1rst working day not the second...

Can you be a bit more clear

Last edited by vbe; 11-08-2011 at 12:55 PM.. Reason: Did not understand the request... (time to leave?)
# 3  
Old 11-08-2011
Quote:
Originally Posted by Hollo
Hello Guys,

I have a questions regarding running a shell script every second working day each month.
I have no clue how solve this problem Smilie.
Important is that it has to be the second working (Mo-Fr).
Example: If 1st and 2nd Days of month are Sat and Sun the script must run on 4th day of month (2n working day) which is Thuesday.

Thanks for your help!

Kind Regards
David
Sat and Sun are not working days (at least where I live).
Your first and send WORKING days of a month don't have to be Monday and Tuesday - they can be anything: they could be Friday and Monday for all we know.
# 4  
Old 11-08-2011
In other words on Friday 1rst it will also run on the next monday no?
And what about Sunday 1rst? ...
# 5  
Old 11-08-2011
Quote:
In other words on Friday 1rst it will also run on the next monday no?
And what about Sunday 1rst? ...
Yes, if friday is the first working day the script must run on monday because SAT and SUN are no working days
Workings Days are from Mon-Fri

As my example shows if SAT is the 1st day of the month then the script must run on thuesday it'll be the 4th day of month, but the 2nd working day of month.
All that'll get more complex if there are public holidays...

Thanks for your help!
# 6  
Old 11-09-2011
So you choose to run every 2,3,4 of the month and in your script you test to execute:
pseudo
Code:
if [ dm = 2 ]
then
    run the job
else
   if [ dm = 3 ]
   then
      if  [ dw = Tuesday ]
      then
          run the job
      fi
   else
   if [ dw = Monday ] or [ dw = Tuesday ]  # => dm = 4 then...
   then
       run the job
   fi
fi

Do you agree?
I'm waiting to see your implementation...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simpler crontab entry to execute pgm on last day of the month

The following bash command line works for the last day of the month. Test by replacing the 1 with tomorrows day of month number && echo "Day before tomorrow"Can it be used within crontab? As * * 28-31 * * && echo "Today ls last day of month" >>/tmp/crontabtestI tried to test crontab with... (1 Reply)
Discussion started by: lsatenstein
1 Replies

2. Shell Programming and Scripting

Find Month first Working Day

Hi, I would like to calculate 1st working/Business day of each month. Exp: 1st -Oct-2011 is Saturday--- Non Business Day So the Next Working Day would be 3-Oct-2011 I need a shell script to calculate the month first business date. (3 Replies)
Discussion started by: koti_rama
3 Replies

3. Shell Programming and Scripting

Need help in running script on last day of month

Hello Experts/Guru, I need a help in running the script on every month last day.... PS: due to some constrain I can't schedule in crontab Requirement: On Jan 31st i want to run some script, similarly on Feb 28th, March 31st, April 30th......till Dec 31st. Please help me by providing... (3 Replies)
Discussion started by: aks_1902
3 Replies

4. Shell Programming and Scripting

Script to counting a specific word in a logfile on each day of this month, last month etc

Hello All, I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer. Any ideas would be appreciated! (5 Replies)
Discussion started by: pnara2
5 Replies

5. Shell Programming and Scripting

How to find the first working day of month ?

Hi, How to find the first working day of month ? My requirement is, I need to call the function only if today is first working day of month. I could find out one function which finds last working day in month in this forum. Can anyone pls let me know for first working day. Thanks. for... (10 Replies)
Discussion started by: vnimavat
10 Replies

6. Shell Programming and Scripting

crontab entry to run every last day of the month

i've created a script which should run every last day of the month. what would be the exact crontab entry for this? thanks! (9 Replies)
Discussion started by: tads98
9 Replies

7. UNIX for Dummies Questions & Answers

cron script -run every 2nd day of month except Monday

I know I can't schedule this in cron and would have to write a wrapper around my script and schedule it in cron ....but not sure how do to this? How do I exclude Monday if the 2nd day of the month falls on a Monday? Thanks. I tried this: 0 0 2 * 0,2-6 command And I know this doesnt... (2 Replies)
Discussion started by: newtou
2 Replies

8. Shell Programming and Scripting

last working day of previous month

Hi, I want a script(ksh) to see if today is the last working day(Mon-Fri) of the month. If it is the last working day I need to print current date, else I need the last working day of previous month. Thanks in advance. (1 Reply)
Discussion started by: rspk_praveen
1 Replies

9. Shell Programming and Scripting

Get Last working day of the month

Hi I need a script to get "Last working day of the month". I will pass the month and year as parameters and i need to get the last working date. Ex for June 2008 the last working day is 30th its monday. for August 2008 the last working day is 29th and it is Friday. ie the last working... (6 Replies)
Discussion started by: manmarirama
6 Replies

10. Shell Programming and Scripting

Write a shell script to find whether the first day of the month is a working day

Hi , I am relatively new to unix... Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell.. This is very urgent. Thanks for ur help... (7 Replies)
Discussion started by: phani
7 Replies
Login or Register to Ask a Question