Why doesn't my Perl script load the module when running cron?

I have a bunch of Perl scripts that all work fine, but should have use Plibdata;at the top.

I installed a cron job that runs (I get a confirmation email from root) and it returns the following error message:

Can't locate Plibdata.pm in @INC (@INC contains: /install/lib /opt/perl58/lib/5.8.8/IA64.ARCHREV_0-thread-multi /opt/perl58/lib/5.8.8 /opt/perl58/lib/site_perl/5.8.8/IA64.ARCHREV_0-thread-multi /opt/perl58/lib/site_perl/5.8.8 /opt/perl58/lib/site_perl .) at ./x line 5.

BEGIN failed--compilation aborted at ./x line 5.

Line 5 is ... you guessed it ... use Plibdata;

I am also trying to set up the environment as such:

use lib "$ENV{CARSPATH}/install/lib";

maybe if I found the location of these plibdata, could I direct it this way?

My cron commands will be executed with help /usr/bin/sh, says crontabs ...

Any suggestions?

This script works from the command line.

+3
source share
6 answers

script, , , , :

cron, - crontab:

* * * * * CARSPATH=/opt/carsi x

.

CARSPATH x lib, .

, cron, - :

* * * * * source specialenv.sh && x

specialenv.sh ( bash)

export CARSPATH=/opt/carsi

crontab, .

+2

, Plibdata. , . , .

:

perl -MPlibdata -e 1

, , :

perl -MPlibdata -le 'print $INC{"Plibdata.pm"}'

, . (, PERL5LIB env var, .) " lib" Plibdata.pm.

, , perl - ( "perl" ) cron ( "BEGIN {print $^ X}" script).

+7

Cron env, env. script ? , env cron .

+6

, Plibdata.pm :

/install/lib /opt/perl58/lib/5.8.8/IA64.ARCHREV_0-thread-multi /opt/perl58/lib/5.8.8 /opt/perl58/lib/site_perl/5.8.8/IA64.ARCHREV_0-thread-multi /opt/perl58/lib/site_perl/5.8.8 /opt/perl58/lib/site_perl

:

  • Plibdata.pm Perl (site_perl ).

  • PERL5LIB ( -I Perl) .

  • use lib script. , use lib , . BEGIN :

    my $env;
    
    BEGIN {
      $env = $ENV{CARSPATH};
    }
    
    use lib "$env/install/lib";
    
+5

cron , , $CARSPATH . cron, script, , .

script:

#!/bin/bash

source ~username/.bash_profile
cd ~username
./script.pl

ksh sh,

#!/bin/sh

. ~username/.profile
cd ~username
./script.pl

. , script , , ./.

source script . , .

~/.bash_profile, ~/.bashrc, ~/.profile, /etc/profile .. - , . , .

+2

"", , DBI Plibdata.

, ... ahhhhh , - , Plibdata

. , ,


... "" /bin/ bash " "
, ,



* * * * * CARSPATH=/opt/carsi ./x

0

Source: https://habr.com/ru/post/1706492/


All Articles