Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask


by steves (Curate)
on Dec 18, 2004 at 14:32 UTC ( #415860=perlquestion: print w/replies, xml ) Need Help??

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.


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

    That was it. Thanks!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://415860]
Approved by castaway
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2023-03-24 03:35 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.