Package: cron
Version: 3.0pl1-100
Tag: patch

Its not a bug (man 5 crontab), Its only a "bizarre behavior" -> Paul Vixie says 
in cron.c code file:

/* the dom/dow situation is odd.  '* * 1,15 * Sun' will run on the
* first and fifteenth AND every Sunday;  '* * * * Sun' will run *only*
* on Sundays;  '* * 1,15 * *' will run *only* the 1st and 15th.  this
* is why we keep 'e->dow_star' and 'e->dom_star'.  yes, it's bizarre.
* like many bizarre things, it's the standard.
*/

I was writting a "php scheduler" when i found this useless behaivor. 

* Solutions:

- A "bash trick". Justin Pryzby suggestion. For example: { [ "`date +w`" -eq 5 
] && command }, only execute the job on Friday.

Its good, but it breaks the sintaxis consistency for me, and its "pretty/more 
difficult" to develop an harmony code parser.

- The other solution is to change the native behaivor, patching the cron code. 

Yes, I know its not the standard, but cron will work in a "logical mode".

I´ve coded a simple patch (attached) for me and for that people who need to 
change it, and then, when you put this in crontab:

* * 1,15 * Fri echo "el nene llora poco"

The "echo" will only be executed on 1 And 15 every month, ONLY if the day of 
the week is Friday.

-

Jesús Feliz Fernández ([email protected])


Attachment: cron-dom-dow.patch
Description: cron-dom-dow.patch

Reply via email to