UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old July 1st, 2004, 09:46 AM
yogi27 yogi27 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Dallas
Posts: 50 yogi27 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Scheduling and adapting the cron job according to the year

Hi,

This cron job is for the month of November only. I want my cron job to execute on the first 3 Thursdays and then on a Tuesday (because the 4th Thursday is Thanksgiving holiday) and then switch back to Thursday iff that year, Nov. has a 5th Thursday. I hope you got the picture.

One possible option is to use counters to count the number of Thursday's and if the counter reaches 4, execute the cron job on a Tuesday. But everytime the perl script finishes execution, the counter value gets initialized to 1 again. This problem is having the latest counter value exists for any other approach also. The only way I figured was to store this counter value in a different file and read/write to that file and I don't want to have multiple files just for storing a single counter value.

I have an idea. If we check what 1st Nov. is (whether a monday or tuesday or ...), we can easily determine the dates that the cron job must execute. For example, if Nov. 1st is a monday, then the cron job must execute on 4, 11, 18 & 23 of November. So the dates will keep changing every year depening on the starting day of November.

My question is, Is there a way by which we can change the date field in the cron command through the perl script? Thus, for 2004 year, the cron job will execute on the above-mentioned dates while it would change for other years.

If there is a better solution to have a general approach so that I dont have to bother about the cron job ever, can someone please help me out. Thank you.

Reply With Quote
  #2  
Old July 1st, 2004, 01:09 PM
jim mcnamara jim mcnamara is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,299 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 8 h 41 m 52 sec
Reputation Power: 47
Tell cron to submit the job every Tuesday & Thursday in November.

The script's first lines of code make the date checks you need. If the date checks fail the job exits early.

Dynamically updating cron for important jobs is a bad idea.
How do you test it? What if the job runs at the wrong time, or never runs? Forget modifying cron, just let the script handle it.

We have a nightly batch routine with about 30 jobs. They are all fired off over period of several hours every night.
They all have a common module that reads what we call a schedule file for jobs that have weird requirements. If a job doesn't find it's name in the schedule file for a range of dates that include today- it looks there first - it then defaults to it's own built-in date check.

Reply With Quote
  #3  
Old July 1st, 2004, 01:41 PM
yogi27 yogi27 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Dallas
Posts: 50 yogi27 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
If I perform date checks, the script would not be generic. I will have to edit the script file next year and make the necessary date checks.

For example, for 2004, I can make the cron job execute only on 4, 11, 18 & 23 of November.

But for 2005, I'll have to change the date checks to 3, 10, 17 & 22 of November and so on for future years.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Scheduling and adapting the cron job according to the year


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway