Config::Crontab reads and writes (and pretty-prints) your crontab(5)
files. It is compatible with Vixie-style crontabs (and all subsets,
including Solaris' SysV-style crontabs).
Config::Crontab has a simple, object-oriented syntax. Crontab files
are broken into "blocks" (paragraphs, each separated by two or more
newlines); the Block is the basic unit of a Config::Crontab object.
You can re-order entire blocks within a crontab file, re-order lines
within blocks (there are three types of lines: comments, environment
settings, and crontab commands or events), remove blocks or lines
within blocks, add new blocks or lines within blocks, etc. See the
Config::Crontab manpage for full details.
Config::Crontab will do basic regular expression syntax checks; it
won't allow obvious garbage (e.g., 'F * * * * /bin/bar' would fail
since 'F' is not valid), but it won't check for nonsensical entries
such as '10-2 * * * * /bin/bar' (the minute range specified is
invalid). However, if you attempt to commit an invalid crontab, the
'write' method will return undef and the 'error' method will be set
(with the output of crontab(1)) if the crontab is rejected by the
crontab program.
EXAMPLES
Example 1:
==========
Consider this example of parsing a crontab, re-schedule a cron event,
and commit the changes. Given:
30 5 * * 1-5 /bin/foo
we want to re-schedule the event to run at 4:30a instead. Here is one
way, creating an B<Event> object:
my $ct = new Config::Crontab; $ct->read;
my ($event) = $ct->select(-command_re => '/bin/foo');
$event->hour(4);
$ct->write;
and here is a shortcut to do the same thing:
my $ct = new Config::Crontab; $ct->read;
($ct->select(-command_re => '/bin/foo'))->hour(4);
$ct->write;
Example 2:
==========
The following example is equivalent to 'crontab -l':
$ct = new Config::Crontab; $ct->read; print $ct->dump;
Example 3:
==========
The following example is equivalent to 'crontab -u joe -l':