|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Scheduling and adapting the cron job according to the year |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|