Skip to content
Advertisement

crontab (cronie), run certain days of the month

I want to make a crontab entry which will run on every weekday except the 1st, 2nd, and 3rd of each month. Here’s what I have:

JavaScript

I thought that this had the following meaning:

JavaScript

That is what I read in the crontab(5) manual page. However, I can see that the job ran at 08:45 today, Monday 2nd October. I am certain the crontab file was loaded correctly (and crontab -l shows it); it wasn’t changed recently. The system date and time as shown by date is also correct.

What am I missing to make sure my cron job only runs from the 4th onwards? I am using Fedora Linux:

JavaScript

Advertisement

Answer

From crontab manual:

Note: The day of a command’s execution can be specified by two fields — day of month, and day of week. If both fields are restricted (i.e., aren’t *), the command will be run when either field matches the current time. For example, “30 4 1,15 * 5” would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday. One can, however, achieve the desired result by adding a test to the command (see the last example in EXAMPLE CRON FILE below).

The mentioned example looks like this:

JavaScript

So in your case it would be like this (not tested):

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement