[CentOS] cron job failures with a perl script containing Astro::Time

Mon Jan 2 23:17:16 UTC 2017
Keith Keller <kkeller at wombat.san-francisco.ca.us>

On 2017-01-02, Gregory P. Ennis <PoMec at PoMec.Net> wrote:
>
> The error message I get in the logs is :
>
> Can't locate Astro/Time.pm in @INC (@INC contains:
> /usr/local/lib64/perl5 /usr/local/share/perl5
> /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl
> /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/bin/s.bkup.degw3.prl
> line 12.
> BEGIN failed--compilation aborted at /usr/local/bin/s.bkup.degw3.prl
> line 12.

[snip]

> The script works find from the command line, but will not work at all
> in a cron job.

This almost always points to something in the environment.

Where did Astro::Time actually get installed?  Check the above paths to
see if it is actually there, or whether cpan put it somewhere else.  If
it put Astro::Time elsewhere, you will need to add a PERL5LIB export to
your crontab file (or better, make a bash wrapper, point cron to that,
and put the PERL5LIB variable there).

If you put it in crontab, you should get the current value from your
shell, and put that into crontab (verify it looks reasonable first).

echo $PERL5LIB
# or
env |grep PERL5LIB

If you don't have PERL5LIB set, you can take the paths you currently
have defined (see your path list above) and add the path to Astro::Time
to that.

--keith


-- 
kkeller at wombat.san-francisco.ca.us