Subject: | handy to use month/dow names per crontab(5) |
From crontab(5) under ubuntu 6.10 (edgy eft):
Show quoted text
> 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 doesn't
> matter). Ranges or lists of names are not allowed.
A quick modification that implements this (without a great deal of
testing) is:
%calnametonum = qw(jan 1 feb 2 mar 3 apr 4 may 5 jun 6
jul 7 aug 8 sep 9 oct 10 nov 11 dec 12
mon 1 tue 2 wed 3 thu 4 fri 5 sat 6 sun 7);
$calregexp = '(' . join('|', keys %calnametonum) . ')';
# ... collect cron specification
$cronspec = lc $cronspec;
$cronspec =~ s/$calregexp/$calnametonum{$1}/gi;
# ... continue to handle cron spec as usual
It's much more lax in input checking, but should handle all legal cases
per the crontab(5) man page. Perhaps this doesn't belong in this
module, but that's up to your discretion.