http://qs321.pair.com?node_id=415860

steves has asked for the wisdom of the Perl Monks concerning the following question:

Has anyone used DateTime::Event::Cron?

It looks useful but I got hung up immediately on some basics. This code should, I think, show me each crontab entry, then show me just the command:
use strict; use DateTime::Event::Cron; my @entries = DateTime::Event::Cron->new_from_crontab (file => '/tmp/crontab.out'); my $entry; foreach $entry (@entries) { print $entry->original(), "\n"; print " ", $entry->command(), "\n"; }
The full entry prints fine, but the commands are all missing the leading token of the command (the program name) -- only the command arguments are shown. I believe all of the commands are full paths and therefore contain forward slashes. Some of the docs. point to an expanded cron syntax that supports slashes, so I'm wondering if maybe that has something to do with it.

At any rate, I'd be interested to hear other monks' experience with this module.

Replies are listed 'Best First'.
Re: DateTime::Event::Cron
by Anonymous Monk on Dec 19, 2004 at 05:03 UTC
    try twiddling the user_mode.
    my @entries = DateTime::Event::Cron->new_from_crontab (file => '/tmp/crontab.out', user_mode => 0);
    systemwide crontabs have a user field (gump):
    * * * * * gump /bin/date
    user crontabs don't:
    * * * * * /bin/date
Re: DateTime::Event::Cron
by mojotoad (Monsignor) on Dec 21, 2004 at 04:28 UTC
    The above answer from Anonymous Monk, regarding tweaking the user_mode parameter, is the correct one as I also answered on the DateTime mailing list.

    It would be useful, however, if you could provide an example crontab entry that is failing, since the module makes an attempt to figure out the correct mode automatically. Something in your particular crontab file is throwing it off and I'd like to know what.

    Cheers,
    Matt

Re: DateTime::Event::Cron
by steves (Curate) on Dec 19, 2004 at 11:01 UTC

    That was it. Thanks!