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::DB2: 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! |
cron job
read:
man cron man crontab man 5 crontab man 1 crontab pay particular attention to cron.allow and cron.deny Larry |
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.
|
Is there a way to find out what I set those two variables to?
Thanks Very Much! Harlin |
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 |
Please post code in [code] tags to improve readability.
|
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 |
Try adding /usr/lib/perl5/5.8.5/i386-linux-thread-multi to your LD_LIBRARY_PATH
|
All times are GMT -5. The time now is 12:17 AM. |