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

Tue Jan 3 15:41:47 UTC 2017
Gregory P. Ennis <PoMec at PoMec.Net>


> 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.



Thanks for your reply.  I am not totally sure what I did when I
installed the Centos 7 on this machine, but I did identify that I had
inappropriately installed perl-File-HomeDir.noarch which I normally do
not use.  

This was the only thing that I identified that was done
differently.  I yum removed perl-File-HomeDir.noarch, but the problem in using Astro::Time from a cron job or an account different than root was not fixed.  I finally wrote a wrapper that sets the environment variables to the same command line env variables as root so that the root cron backup routines would work.

I spent about 8 hours trying to fix this problem, but finally the
wrapper bypass was the only thing that worked.   I not totally sure if 
perl-File-HomeDir.noarch was the culprit, but I will certainly be
careful not to install it again.

Thanks for your help !!!