Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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.

In reply to Re: Adding into a users crontab by kyle
in thread Adding into a users crontab by ninjaspydr

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2022-05-24 05:12 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (82 votes). Check out past polls.