cron job not firing off perl script -- 'use' statements stopping it
by nachtmsk from LinuxQuestions.org on (#5C9YF)
Hi,
I have a perl script that wasn't getting run by (root) cron.
I wrote another small script to test it and included the same 4 mods I was running in the initial script.
Apparently the script won't run if the three "use" statements I have commented out are un-commented
1. The script runs and processes correctly if I run it by hand. Permissions on the script are good. Directory permissions are good.
2. The script will run in cron if I comment out those three 'use' statements. It's fine with the DBI mod
3. I reinstalled those three mods via cpan, to make sure they were installed correctly.
4. No errors from the cron. I tried running it both from the root cron and the user 'pi' cron.
This one has me stumped.
Here is the cron and the script.
--- script --
#!/usr/bin/perl
# Used to test things.
#use LWP::Simple;
#use Data::Dumper;
#use Mojo::JSON;
use DBI;
open(LOGS, ">>/home/pi/logs/weather.log") or warn "Can't open log $! ";
print LOGS " Hello again\n";
close(LOGS);
---------
---- ROOT CRON ----
*/2 * * * * /home/pi/scripts/test.pl &>> /home/pi/logs/cron.log


I have a perl script that wasn't getting run by (root) cron.
I wrote another small script to test it and included the same 4 mods I was running in the initial script.
Apparently the script won't run if the three "use" statements I have commented out are un-commented
1. The script runs and processes correctly if I run it by hand. Permissions on the script are good. Directory permissions are good.
2. The script will run in cron if I comment out those three 'use' statements. It's fine with the DBI mod
3. I reinstalled those three mods via cpan, to make sure they were installed correctly.
4. No errors from the cron. I tried running it both from the root cron and the user 'pi' cron.
This one has me stumped.
Here is the cron and the script.
--- script --
#!/usr/bin/perl
# Used to test things.
#use LWP::Simple;
#use Data::Dumper;
#use Mojo::JSON;
use DBI;
open(LOGS, ">>/home/pi/logs/weather.log") or warn "Can't open log $! ";
print LOGS " Hello again\n";
close(LOGS);
---------
---- ROOT CRON ----
*/2 * * * * /home/pi/scripts/test.pl &>> /home/pi/logs/cron.log