LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-15-2007, 08:48 AM   #1
Harlin
Member
 
Registered: Dec 2004
Location: Atlanta, GA U.S.
Distribution: I play with them all :-)
Posts: 316

Rep: Reputation: 30
Script works when run manually but not in cron job


I have a script that runs like so:

-----------------------------------------------
pth=/home/namor/wasson
node=lmsshadp
uid=chiller
pw=bechillin
log=$pth/wasson.log

echo JOB START >> $log
perl -X $pth/wasson4m.pl $node $uid $pw $log
perl -X $pth/wasson4t.pl $node $uid $pw $log
perl -X $pth/wasson4l.pl $node $uid $pw $log
perl -X $pth/wasson1l.pl $node $uid $pw $log
perl -X $pth/wasson1t.pl $node $uid $pw $log
perl -X $pth/wasson1m.pl $node $uid $pw $log
perl sendout.pl
echo JOB END >> $log
-----------------------------------------------

It is called 'crun.' It is placed in the crontab -e like so:

-----------------------------------------------
# CRun
0 7 * * * /home/namor/wasson/crun
# This file was written by KCron. Copyright (c) 1999, Gary Meyer
# Although KCron supports most crontab formats, use care when editing.
# Note: Lines beginning with "#\" indicates a disabled task.
-----------------------------------------------

"crun" runs fine when called manually. However, I get some very weird errors when called from cron like this one showing up in the mail:

install_driver(DB2) failed: Can't load '/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/DB2/DB2.so' for module DBD:B2: libdb2.so.1: can't open shared object file: No such file or directory at /usr/lib/perl5/5.8.5/i386-linux-thread-multi/DynaLoader.pm line 230.
at (eval 3) line 3
Compilation failed in require at (eval 3) line 3.
Perhaps a required shared library or dll isn't installed where expected
at /home/namor/wasson/wasson4m.pl line 28

Anyone have any idea why this doesn't run properly when called from cron?

Thanks!
 
Old 10-15-2007, 09:22 AM   #2
lweldon
LQ Newbie
 
Registered: Jan 2006
Posts: 1

Rep: Reputation: 0
cron job

read:
man cron
man crontab
man 5 crontab
man 1 crontab

pay particular attention to cron.allow and cron.deny

Larry
 
Old 10-15-2007, 09:33 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
When running from cron you do not get the same environment variables set as you do when you run from your login shell. It looks from the output you provided that you need to explicitly set the PERL5LIB and possible the LD_LIBRARY_PATH in your script.
 
Old 10-16-2007, 04:37 PM   #4
Harlin
Member
 
Registered: Dec 2004
Location: Atlanta, GA U.S.
Distribution: I play with them all :-)
Posts: 316

Original Poster
Rep: Reputation: 30
Is there a way to find out what I set those two variables to?

Thanks Very Much!

Harlin
 
Old 10-16-2007, 04:46 PM   #5
Harlin
Member
 
Registered: Dec 2004
Location: Atlanta, GA U.S.
Distribution: I play with them all :-)
Posts: 316

Original Poster
Rep: Reputation: 30
I've got this in my crontab -e :

LD_LIBRARY_PATH=/home/db2inst1/sqllib/lib
# Folders to search for program files.
PATH=$PATH:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/opt/ibm/director/bin:/home/mmiller/bin:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc
PERL5LIB=/usr/lib/perl5/5.8.5/
CLASSPATH=/home/db2inst1/sqllib/java/db2java.zip:/home/db2inst1/sqllib/java/db2jcc.jar:/home/db2inst1/sqllib/java/sqlj.zip:/home/db2inst1/sqllib/function:/home/db2inst1/sqllib/java/db2jcc_license_cisuz.jar:/home/db2inst1/sqllib/java/db2jcc_license_cu.jar:.
DB2INSTANCE=db2inst1
LIBPATH=/home/db2inst1/sqllib/lib
VWSPATH=/home/db2inst1/sqllib
EXEC=/home/mmiller/.bash_profile
# matt's check
0,10,20,30,40,50 * * * * /home/mmiller/wasson/drun
# crun
0 7 * * * /home/mmiller/wasson/crun
# This file was written by KCron. Copyright (c) 1999, Gary Meyer
# Although KCron supports most crontab formats, use care when editing.
# Note: Lines beginning with "#\" indicates a disabled task.

So, we've got all the environment variables set in here. Does anyone have any clue why this isn't working?

Thanks
 
Old 10-16-2007, 05:02 PM   #6
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
Please post code in [code] tags to improve readability.
  1. Do you get the error when you run from your interactive shell?
  2. Do you still get the error about libdb2.so.1 from either the interactive shell or when running from cron?
  3. Can you locate this file, libdb2.so.1?
 
Old 10-16-2007, 05:50 PM   #7
Harlin
Member
 
Registered: Dec 2004
Location: Atlanta, GA U.S.
Distribution: I play with them all :-)
Posts: 316

Original Poster
Rep: Reputation: 30
1. No
2. Only when running from cron
3. Locations below:

/opt/IBM/db2/V8.1/lib/libdb2.so
/opt/IBM/db2/V8.1/lib/libdb2.so.1
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/libdb2.so.1
 
Old 10-16-2007, 06:36 PM   #8
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
Try adding /usr/lib/perl5/5.8.5/i386-linux-thread-multi to your LD_LIBRARY_PATH
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Backup script won't run in cron job. Why? Micro420 Linux - General 19 10-31-2007 08:26 PM
script does not run in cron job kashyapvirgo Linux - General 8 03-20-2007 10:55 AM
How to write a script to run bitdefender antivirus as a cron job? ginda Linux - Software 1 03-10-2005 08:08 PM
how to run this cron job ashley75 Linux - General 5 05-24-2004 11:20 AM
shell script fo run auto job in cron JolynnMarie LinuxQuestions.org Member Intro 0 04-28-2004 11:21 AM


All times are GMT -5. The time now is 08:50 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration