1751937 Members
4534 Online
108783 Solutions
New Discussion

Re: crontab behaviour

 
EU-Admins-UNIX
Regular Advisor

crontab behaviour

Hi

 

Last week i scheduled a cron job to run at 0945 Wed 17 April.

 

I scheduled the following:

 

45  9  17  4   2

 

By mistake I put '2' for Wednesday, where I should've put '3'.

 

The thing is it ran OK last Wednesday, despite the day number being wrong (2, not 3), and having not removed the job, it also ran this morning, with the date being wrong (25, not 17). How can that be?  Is that normal bahaviour?

 

Looks like it'll run every Tuesday in April?

 

Regards

 

Tariq

1 REPLY 1
Matti_Kurkela
Honored Contributor

Re: crontab behaviour

From "man crontab":

Note that the specification of days can be made in two fields: monthday and weekday.
If both are specified in an entry, they are cumulative.  For example,

      0   0   1,15   *   1   command

runs command at midnight on the first and fifteenth of each month, as
well as every Monday.  To specify days in only one field, set the
other field to asterisk (*).  For example,

      0   0   *   *   1   command

 

So the job you scheduled would run on every Tuesday in April, *and* on April 17 every year whether it is Tuesday or not.

MK