|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
|||
|
|||
|
Quote:
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 |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Interpretation of same cron job in different ways |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|