LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-28-2009, 07:16 AM   #1
emymcse
LQ Newbie
 
Registered: Jun 2006
Posts: 10

Rep: Reputation: 0
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 ?
 
Old 12-28-2009, 07:25 AM   #2
junaid18183
Member
 
Registered: Mar 2005
Location: India
Distribution: RedHat 9.0 and EL
Posts: 31

Rep: Reputation: 15
Looks like you are using some perl module and the path for that module is not present in @INC.
 
Old 12-28-2009, 07:27 AM   #3
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
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
 
Old 12-28-2009, 07:38 AM   #4
junaid18183
Member
 
Registered: Mar 2005
Location: India
Distribution: RedHat 9.0 and EL
Posts: 31

Rep: Reputation: 15
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);"
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
script does not run in cron job kashyapvirgo Linux - General 8 03-20-2007 10:55 AM
Bash script and cron job rust8y Linux - General 2 07-08-2006 07:45 AM
Cron Job with a Script bravored Linux - General 4 08-05-2005 10:27 AM
script not running as a cron job sanjith11 Programming 5 11-23-2004 08:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration