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:
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  
Old June 21st, 2004, 09:08 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: 5
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.

Reply With Quote
  #2  
Old June 21st, 2004, 09:26 AM
zby zby is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Location: Prague, Czech Republic
Posts: 825 zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level)zby User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 16 h 4 m 55 sec
Reputation Power: 65
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.

Reply With Quote
  #3  
Old June 21st, 2004, 10:35 AM
stevengs stevengs is offline
Permanently Banned
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: Germany
Posts: 394 stevengs User rank is Lance Corporal (50 - 100 Reputation Level)stevengs User rank is Lance Corporal (50 - 100 Reputation Level)stevengs User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 Days 4 h 36 m 24 sec
Warnings Level: 10
Number of bans: 1
Reputation Power: 0
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

Reply With Quote
  #4  
Old June 25th, 2004, 01:35 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: 5
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.

Reply With Quote
  #5  
Old June 25th, 2004, 02:50 PM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,307 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 3 Days 4 h 28 m 57 sec
Reputation Power: 48
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > How do I skip a few days in Unix cron command?


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


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





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