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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old June 29th, 2004, 06:02 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
Interpretation of same cron job in different ways

This is my cron command:

0 15 29,30 6 3 cat data >> data.old

If I am correct, the command should execute only on June 30 since 30th is a Wednesday. But, it executed on June 29 even thought 29th is a Tuesday.

This is what I read in the man pages:
0 0 1,15 * 1 would run the command on the first and fifteenth of each month, as well as on every Monday. To specify days by only one field, the other field should be set to *. For example, 0 0 * * 1 would run a command only on Mondays.

I got this info online:
Assuming June 15 is a Monday,
0 0 1,15 6 1 would run the job on the 1st only if the first is also a Monday, and in 0 0 1-15 6 1 the job will execute only on those days between the 1st and the 15th which are also Mondays.

Why is there a conflicting view? Can someone please tell me how do I solve this issue?

Reply With Quote
  #2  
Old June 29th, 2004, 10:59 PM
bingotailspin's Avatar
bingotailspin bingotailspin is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 115 bingotailspin User rank is Corporal (100 - 500 Reputation Level)bingotailspin User rank is Corporal (100 - 500 Reputation Level)bingotailspin User rank is Corporal (100 - 500 Reputation Level)bingotailspin User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 52 m 45 sec
Reputation Power: 7
This sounds like a precedence problem, you could just separate your cases over multiple lines. This will allow you to be specific about when the job needs to run and allow others to easily see what's going on without understanding the precedence rules.

Reply With Quote
  #3  
Old June 30th, 2004, 12:04 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
Quote:
I got this info online:
Assuming June 15 is a Monday,
0 0 1,15 6 1 would run the job on the 1st only if the first is also a Monday, and in 0 0 1-15 6 1 the job will execute only on those days between the 1st and the 15th which are also Mondays.


The information in the manpage is true ( always. the manpages are THE defacto source ). The information you found on the internet is incorrect and probably wishful thinking on the part of the author.

The internet is kinda like tv, you have to second guess everything. 80% of what you find is based on personal opinion, and most of that is pure hogwash. If in doubt, consult the manpage. Or better yet, always consult the manpage first (as you did here, which is commendable), and if you do not understand something, then google.

If you want a task performed on the 29th or 30th of June only in case one falls on a Wednesday (I am guessing that that is what you are aiming for), cron alone will not serve you. Your best bet would be to set the cronjob to run on the 29th and 30th of June,

Code:
0  15  29,30  6  *  my_executable_script


and then write my_executable_script, in which you enclose the cat command in an if construct, that tests whether the current day is Wednesday.

-Steven
__________________
My mother told me to stand up to homicidal maniacs. –Baldrick
Yes, if this is the same mother who confidently claimed that you are a tall handsome stallion of a man, I should treat her opinions with extreme caution. –Edmund Black Adder

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Interpretation of same cron job in different ways


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