Hi
I have a perl script that runs OK from the terminal but won't run from cron. I get a logged error that looks like this:
May 24 09:00:02 trackcam3 test_cron: Can't locate Image/Grab.pm in @IN
+C (you may need to install the Image::Grab module) (@INC contains: /e
+tc/perl /usr/local/lib/arm-linux-gnueabihf/perl/5.24.1 /usr/local/sha
+re/perl/5.24.1 /usr/lib/arm-linux-gnueabihf/perl5/5.24 /usr/share/per
+l5 /usr/lib/arm-linux-gnueabihf/perl/5.24 /usr/share/perl/5.24 /usr/l
+ocal/lib/site_perl /usr/lib/arm-linux-gnueabihf/perl-base) at /home/d
+arren/upload_image.pl line 33, <DATA> line 1.
May 24 09:00:02 trackcam3 test_cron: BEGIN failed--compilation aborted
+ at /home/darren/upload_image.pl line 33, <DATA> line 1.
So I ran:
darren@trackcam3:~ $ cpan Image::Grab
Loading internal null logger. Install Log::Log4perl for logging messag
+es
Reading '/home/darren/.cpan/Metadata'
Database was generated on Wed, 23 May 2018 19:54:03 GMT
Image::Grab is up to date (1.4.2).
This looks like cron doesn't have the right path in the environment
The path statement in crontab looks like:
PATH=/home/darren/perl5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin
+:/usr/bin:/sbin:/bin
# PATH =/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
The uncommented path is the same as the one in my user profile.
The commented path is the one that has worked for years.
This problem started when I build a new server from scratch using a documented procedure. Something I have done quite a few times. Something new has happened during the build. I don't know what that was and I don't know how to solve this problem.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.