|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
How do I skip a few days in Unix cron command?
Hi,
I want to skip a few days in the year (e.g. June 25,26,27 & 28) i.e. my cron job should not work during these days. Can anyone please help me out with this. Thank you. |
|
#2
|
|||
|
|||
|
What if you:
Code:
00 23 07 24 * /usr/local/bin/remove_my_job_script_out_of_path.sh off 00 23 07 28 * /usr/local/bin/remove_my_job_script_out_of_path.sh back 00 03 * * * /usr/local/bin/myjob.sh Could that do your job? If so, test it first. ![]() |
|
#3
|
|||
|
|||
|
you could also just set the crontab to fit. (read "man 5 crontab" for the exact rules)
example: Code:
# ORDER: # Minute : Hour : Day-o-Month : Month : WeekDay # First rule for 1:00 AM every day of the year except June: 0 1 * 1-5,7-12 * username /usr/sbin/command | mailto # Second rule for June (every day except 24,25,26,27) 0 1 1-23,28-30 6 * username /usr/sbin/command | mailto As you can read in the manpage for crontab (5), you can set ranges and series (or sequences). Ranges are hyphen separated (i.e. 1-5), and sequences are comma separated (i.e. 1,2,5,6,8,11). You can also choose a stepping with a '/'. "1-22/2" means 1 through 22, in steps of 2, or "1,3,5,7,9,11,13,15,17,19.21...". These rules are specific to my cron. Yours may differ somewhat, so it is a good idea to have a glance at the manpage in any case (depending on whether you use vixiecron, fcron, dcron,...). Have fun. -Steven __________________ You ride a horse rather less well than another horse would. –Edmund Black Adder |
|
#4
|
|||
|
|||
|
Skipping a few days in Unix cron command
Hi,
The command that Steven gave would work. Is there any a shorter command to execute this: All days in a year EXCEPT Nov. 25, 26 and Dec. 27,28,29,30,31 WinCron has a -skip year command where you can specify the days of the year you DO NOT want your cron job to run e.g. Jan 01 = 1, Jan 02 = 2, Dec 31 = 365 I tried this command in Unix but it doesn't work. Is there anything like this in Unix? Thank you. |
|
#5
|
|||
|
|||
|
How about dacron? (joke)
Generally folks try to get cron to do too much. Try putting some time tests in a script, then let cron submit it. -- the script checks the date and exits if there is a reason to leave early. This kind of thing is good for the "2nd Tuesday of each month" kind of thing. overloading cron with complex submission criteria usually gets you in trouble. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > How do I skip a few days in Unix cron command? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|