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