I'm not sure if your script runs at all. If the shown line is your crontab entry, there must be an additional script root involved, which might be (yet another) cause for the script behaving weird.

My list of things that I check whenever I wrote a new script being started via cron is the following:

  1. Working directory. My versions of cron start the scripts in /, and most likely that is not writable to the user the script runs as. Doing a cd $(dirname $0); respectively use File::Basename; chdir dirname($0) or die "Couldn't change to $0 : $!"; fixes that in my cases.
  2. Environment. cron dosen't set many environment variables that my .bashrc, .kshrc or .profile set. tilly wrote a [id://snippet] to get the default login environment variables defined in these files, but I normally use a small shell wrapper around my scripts if they require values in %ENV: . ~/.profile; exec ~/my/script.pl
  3. $ENV{PATH} Courtesy of bart This is a special case of the above, the path is most likely not set or set to something very restrictive like /bin:/usr/bin. Explicitly setting it in the (Perl) script works well here.
  4. The log files. My interesting scripts log their complete run into logfiles. What do the logfiles tell? If there is a compilation error (or missing modules, see Environment above) etc., the shell wrapper logs at least the start of the Perl script.
  5. Email recipient. cron should mail me the output (if any). Is the email recipient for the crontab set at all? Does that account have a (working) .forward file?

Update: Added link to tillys snippet

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

In reply to Re: cron/perl interaction gotchas i am missing? by Corion
in thread cron/perl interaction gotchas i am missing? by schweini

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.