Run A Job in Cron On A Specific Day Excluding Holidays


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Run A Job in Cron On A Specific Day Excluding Holidays
# 1  
Old 09-04-2012
Run A Job in Cron On A Specific Day Excluding Holidays

Hi,
I want to run a job in cron on a specific date(say 25th of every month) excluding holidays. Can anyone provide some hints to do this? Thanks for any inputs.
# 2  
Old 09-04-2012
Holidays are often company specific - like in the US a lot of companies grant the day after Thanksgiving.

Put a holiday schedule, updated every year, in a place where your code can read it. Determining holidays has to be up to the script. UNIX does not have such a thing.

Ex:
Code:
# holiday file
# Christmas
12-25-2012

crontab
Code:
* * 25 * *  /path/to/my/script.sh >/path/to/logfile 2>&1

In script.sh:
Code:
#!/bin/bash
today="`date +%m-%d-%Y`"
grep -qF "$today" /path/to/holidayfile && exit    # do not run on holidays
...rest of script here.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX cron job is running everyday instead of on a particular day

Hello, I was trying to run a script on a dev server using cron job. It supposed to run 3rd sunday of every month. 45 4 15-21 * 0 /home/user1/myscript.sh >/dev/null 2>&1 # run this script 3rd sunday of every month When I Schedule it on AIX server, It is running every day at 4:45 AM. am I... (3 Replies)
Discussion started by: Kumar7997
3 Replies

2. Shell Programming and Scripting

Cron job cannot run the command

Hi, I created this cron job for asterisk to send sms daily to a number #!/bin/sh #custom mod - send sms once a day, at 07:00. CRON_PATH="/etc/asterisk/gw/crontabs_root"; if ! grep 'gsm send sms' $CRON_PATH > /dev/null 2>&1 ;then echo "* 7 * * * asterisk -rx 'gsm send sms 1 7666... (4 Replies)
Discussion started by: jazzyzha
4 Replies

3. Shell Programming and Scripting

Cron Job to Run for 30 minutes

Hello Gurus, I have a requirement to run a job from cron only for 30 minutes duration daily twice at 8.35 am and 20.35 pm Can you please suggest how to schedule the job? Thanks- Pokhraj (5 Replies)
Discussion started by: pokhraj_d
5 Replies

4. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

5. Shell Programming and Scripting

Autosys job scheduling on specific day

Below is the requirement i am trying to do using auto sysjob. I need to create a JOB or script which will do the below things for me I have a box and there corresponding jobs as below BOX_1 JOB_1 JOB_2 BOX_2--- SU(JOB_2), this will run only on completion (Success) of JOB_2 ... (2 Replies)
Discussion started by: j_panky
2 Replies

6. Shell Programming and Scripting

Cron job randomly once a day

I want to create a cron job randomly once a day for my site's registration. The responsible file for registrations is a config file and I need to change the contents twice on day (on and off) I know the way for random cron job for example */n * * * * /usr/local/bin/php... (6 Replies)
Discussion started by: lucker
6 Replies

7. UNIX for Advanced & Expert Users

Use cron to run job every other week

my colleague was asking about this: is there a way to run a cron job biweekly, like a script five.sh to run every *OTHER* Friday within November its part about every other Friday we cant find any documentation. thx L (8 Replies)
Discussion started by: lydiaflamp
8 Replies

8. 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

9. UNIX for Advanced & Expert Users

Need help with a script run by a cron job.

Hi, new to this forum and not sure if this is the right place to post. I'm new to cron jobs and scripts, and I need some help with a script to be used with a cron job. I already have a bot set up at a certain website address and need a script that the cron job will load every day that tells it to... (1 Reply)
Discussion started by: klawless
1 Replies

10. Shell Programming and Scripting

Does not run via cron job

I have a perl script, when I ran manually it works perfect. I check the permissions which are fine. How can I find out why it is not running? how can I setup a log to check. I am running it on solaris 9. It compares multiple files, SCP and then send out an e-mail. As I said when I ran it... (2 Replies)
Discussion started by: amir07
2 Replies
Login or Register to Ask a Question