Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs regarding named ranges or lists incorrect? #62

Closed
preed opened this issue Jul 12, 2020 · 2 comments
Closed

Docs regarding named ranges or lists incorrect? #62

preed opened this issue Jul 12, 2020 · 2 comments

Comments

@preed
Copy link
Contributor

preed commented Jul 12, 2020

I believe the following verbiage in man/crontab.5 is incorrect:

Names can also be used for the 'month' and 'day of week' fields.  Use the
first three letters of the particular day or month (case does not
matter).  Ranges or lists of names are not allowed.

I perused the source code, and based on my reading (which you shouldn't trust :-) believe that the code indeed does convert weekday and month names into integers, and then uses the integers to trigger on the appropriate range (or list) of days (or months); see: https://github.com/cronie-crond/cronie/blob/master/src/entry.c#L248-L264 and https://github.com/cronie-crond/cronie/blob/master/src/entry.c#L438

I also just ran a test (just to be sure my reading of the source wasn't entirely off) using the follow crontab entries, and have been getting emails as expected all week:

0 12 * * mon-fri echo "Cronie day range test: $(date +\%a)"
0 12 * * sat,sun echo "Cronie day list test: $(date +\%a)"

I didn't try named month lists or ranges, but looking at the code, it uses very similar logic for month-names, so it seems like it should also work.

I suggest the following patch:

diff --git a/man/crontab.5 b/man/crontab.5
index 2ee9feb..abe2b1c 100644
--- a/man/crontab.5
+++ b/man/crontab.5
@@ -212,7 +212,8 @@ two hours, you can use "*/2".
 .PP
 Names can also be used for the 'month' and 'day of week' fields.  Use the
 first three letters of the particular day or month (case does not
-matter).  Ranges or lists of names are not allowed.
+matter).  Ranges and lists of names are allowed. Examples: "mon,wed,fri",
+"jan-mar".
 .PP
 If the UID of the owner is 0 (root), the first character of a crontab
 entry can be "-" character. This will prevent cron from writing a syslog
@t8m
Copy link
Member

t8m commented Jul 13, 2020

Would you like to submit the patch as pull request?

preed added a commit to preed/cronie that referenced this issue Jul 14, 2020
… crontab entries.

The crontab.5 manpage claims "Names can also be used for the 'month' and 'day of week' fields. ... Ranges or lists of names are not allowed." Based on my reading of the source code (not entirely to be trusted) and an experiment I ran (more trustworthy), this is not actually true.

See cronie-crond#62 for more info.
t8m pushed a commit that referenced this issue Jul 14, 2020
… crontab entries.

The crontab.5 manpage claims "Names can also be used for the 'month' and 'day of week' fields. ... Ranges or lists of names are not allowed." Based on my reading of the source code (not entirely to be trusted) and an experiment I ran (more trustworthy), this is not actually true.

See #62 for more info.
@t8m
Copy link
Member

t8m commented Jul 14, 2020

Fixed by #63

@t8m t8m closed this as completed Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants