Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Adding into a users crontab

by kyle (Abbot)
on Jan 09, 2007 at 19:27 UTC ( #593774=note: print w/replies, xml ) Need Help??


in reply to Adding into a users crontab

Are you trying to modify an existing crontab to run your script, or are you trying to get your script to act as if it is the scheduler?

If you want to modify the user's crontab, you might be able to do something like this:

open my $ct_in, '-|', 'crontab -l' or die "Can't read crontab: $!"; my $crontab_contents = do { undef $/; <$ct_in> }; close $ct_in or die "Can't close crontab after read: $!"; open my $ct_out, '|-' 'crontab -' or die "Can't write new crontab: $!" print $ct_out $crontab_contents; print $ct_out "\n"; print $ct_out "*/5 * * * * /every/five/minutes\n"; close $ct_out or die "Can't close crontab after write: $!";

You can get the format of the crontab file from man 5 crontab.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://593774]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-05-21 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (78 votes). Check out past polls.

    Notices?