in reply to Re: CRON job failing but manual run works
in thread CRON job failing but manual run works

Below is the outputs:


[ /]# perl -le 'print for grep {$_ ne q{.}and -d} @INC' /root/perl5/lib/perl5/x86_64-linux-thread-multi /root/perl5/lib/perl5/x86_64-linux-thread-multi /root/perl5/lib/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5

[ /]# find -name OpenSSH ./root/Net-OpenSSH-0.57/lib/Net/OpenSSH ./root/Net-OpenSSH-0.57/blib/arch/auto/Net/OpenSSH ./root/Net-OpenSSH-0.57/blib/lib/auto/Net/OpenSSH ./root/Net-OpenSSH-0.57/blib/lib/Net/OpenSSH ./root/perl5/lib/perl5/x86_64-linux-thread-multi/auto/Net/OpenSSH ./root/perl5/lib/perl5/Net/OpenSSH

So it appears that since I run the script manually as "root" (issues on the practice using of the root user aside) it is using a different install of Perl than CRON, correct?


Would putting the below in the script be a good option or is there a better option?

BEGIN { push @INC,( ./root/perl5/lib/perl5' ); }

Replies are listed 'Best First'.
Re^3: CRON job failing but manual run works
by bart (Canon) on Aug 15, 2012 at 20:40 UTC
    So it appears that since I run the script manually as "root" (issues on the practice using of the root user aside) it is using a different install of Perl than CRON, correct?
    Use the full path to perl in cron. That's the easiest approach.
Re^3: CRON job failing but manual run works
by kcott (Archbishop) on Aug 15, 2012 at 20:41 UTC

    I don't know anything about your system but probably wouldn't advise hacking the perl script itself. Instead, I'd create a shell script for cron to run using the shell script's absolute pathname.

    In that script I'd set up whatever environment variables that cron either doesn't know about or uses some default value that isn't what you want - man 5 crontab should provide that information. One of those environment variables might be PERL5LIB which modifies @INC - see perlrun - ENVIRONMENT.

    The shell script would then run the perl script using the absolute pathname of the perl you want to use. You might want to use command switches such as -Idirectory which modifies @INC - see perlrun - Command Switches.

    -- Ken

Re^3: CRON job failing but manual run works
by Dranzaz (Sexton) on Aug 15, 2012 at 19:58 UTC

    I added the following Line to craontab:

    perl -le 'print for grep {$_ ne q{.}and -d} @INC' > /tmp/croninc.log

    and the following was the output:

    more croninc.log
    /usr/lib64/perl5/vendor_perl
    /usr/share/perl5/vendor_perl
    /usr/lib64/perl5
    /usr/share/perl5