LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   runing sh script in cron job (https://www.linuxquestions.org/questions/linux-general-1/runing-sh-script-in-cron-job-778454/)

emymcse 12-28-2009 07:16 AM

runing sh script in cron job
 
Dear all,

I've created linux sh script that call perl script to backup database , the script is :

#!/bin/bash
cd /aptest/www/aptest/html/atm/bin
perl exportAll.pl /AptestDB-Backup/"`date +%d%m%y`" >> /AptestDB-Backup/logs/"`date +%d%m%y`".txt


the scrip run very well from shell , but when I call that script from cron job got this error :

Your "cron" job on q-aptest
/AptestDB-Backup/scripts/backup.sh

produced the following output:

Can't locate Archive/Zip.pm in @INC (@INC contains: /usr/perl5/5.8.4/lib/i86pc-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/i86pc-solaris-64int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/i86pc-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl . /aptest/www/aptest/html/atm /aptest/www/aptest/html/atm/lib) at exportAll.pl line 95.
BEGIN failed--compilation aborted at exportAll.pl line 95.

can anyone help me to resolve this issue ?

junaid18183 12-28-2009 07:25 AM

Looks like you are using some perl module and the path for that module is not present in @INC.

Disillusionist 12-28-2009 07:27 AM

Cron runs with a minimalistic environment set up, this is by design.

If you need the $PATH environment variable to contain something specific, you will need to export it at the start of your script.

Example:
Code:

export PATH=$PATH:/my/directory

junaid18183 12-28-2009 07:38 AM

I think the problem is not in the shell script, as the error suggested. The error suggest the problem is in exportAll.pl file.

emymcse please provide the full directory path of perl module in your code before using the zip.pm module



FYI ...
The @INC array is a list of directories Perl searches when attempting to load modules. To display the current contents of the @INC array:

perl -e "print join(\"\n\", @INC);"


All times are GMT -5. The time now is 02:41 AM.