Bug 173795
| Summary: | Cron seems to ignore Day Of Month | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Phirsk <fedora> |
| Component: | cronie | Assignee: | Tomas Mraz <tmraz> |
| Status: | CLOSED UPSTREAM | QA Contact: | Brock Organ <borgan> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | rawhide | CC: | grdetil |
| Target Milestone: | --- | Keywords: | FutureFeature |
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Enhancement | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2016-05-12 10:20:55 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
|
Description
Phirsk
2005-11-21 10:29:22 UTC
This issue is noted in the crontab(5) man-page:
" 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 (ie,
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.
"
So your specification:
30 8 1-7 * 0 /<path-to-script>
would run when EITHER the day-of-week is 0 (Sunday) OR the day-of-month is
between 1 and 7 .
This is the way vixie-cron is currently designed to work, and hence this is
not a bug. We could not change this default behaviour without causing problems
to users who relied on it.
But I will consider this bug as an enhancement request to provide some kind of
"AND" option that would make the condition true only if ALL time specifications
matched for a job, as done by the fcron package.
As a workaround, you can add the following to the start of your script, so that it will exit unless it detects that it's running on the first Sunday of the month: case "`LOCALE=C date`" in Sun\ ???\ \ [1-7]\ *) ;; # OK, first Sunday of month *) exit ;; # otherwise quit esac That way the script could run every Sunday (or even every day, or the first 7 days of the month) and only continue on if it is indeed the first Sunday of the month. Similarly, you could replace the "???" with the 3-letter abbreviation of a specific month if you wanted to run on the first Sunday of that month, e.g. "Jan" to run on the first Sunday of the year. You could get even more elaborate by using the "+FORMAT" option to the date command (see "man date") to select on all sorts of date/time fields. You may find with this technique that there's really no need to change the crontab format to accomodate more complicated combinations of time specifications. You can also use @monthly in /etc/anacrontab, if you want only one run per month. But I like to add to cron AND, OR option, which allow this (#0) behaviour. This package has changed ownership in the Fedora Package Database. Reassigning to the new owner of this component. |