Description of problem: Cron jobs for every second Sunday does not work. It shows 22nd as next occurrence.
Cron line used - 0 4 8-14 * 0, it should run only only between 8-14. But next run shows on 22nd of that month.
Version-Release number of selected component (if applicable):
How reproducible: Always
Steps to Reproduce:
1. Monitor > Jobs > create a new job with cronline 0 4 8-14 * 0
2. The recurring logic shows next occurrence on 22nd.
Actual results: Job running on 22nd
Expected results: Job should run only on second sunday
From man 5 crontab:
Note: The day of a command's execution can be specified in the following two fields — 'day of month', and 'day of week'. If both fields are restricted (i.e., do not contain the "*" character), 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.
According to this the cronline you provided would run a job at 4AM every day from 8th to 14th and on every Sunday.
Reading the customer case it seems they were reading upstream documentation where this case is described with an error and I'll fix it there. The only way they could do it would be to have the job run on every day from 8th to 14th and start the script with a check for the day of the week and exiting early in case the day of the week is not Sunday, which roughly translates to what they were doing on RHEL with 0 4 8-14 * * [[ date +%a == "Sun" ]] && echo "some task".
The manpage piece leads me to believe our implementation adheres to the de-facto standard and we shouldn't deviate from it. I'll close this bug now, please feel free to reopen it if you feel strongly about it.
As mentioned, 0 4 8-14 * * [[ date +%a == "Sun" ]] && echo "some task" works for rhel but not on satellite via cronline.
Is there any way to execute job on second Sun of every month?
0 4 8-14 * * [[ date +%a == "Sun" ]] can be roughly translated to "on days matching 0 4 8-14 * *" run "[[date +%a == 'Sun' ]] && somescript".
You can do exactly the same in satellite, you specify a job with "0 4 8-14 * *" cronline and prefix the executed script with
if [[ date %a == 'Sun' ]]; then
# The actual script goes here
So on every day from the 8th to the 14th the job will run against the host and check if it is the right day, in which case it will do what is needed, otherwise it will skip it and exit.
In other words, you have to split the cronline you would specify on RHEL into two parts, into the time specification (the first five fields) and the command (the rest).