Getting error when running script through crontab


 
Thread Tools Search this Thread
# 1  
Getting error when running script through crontab

Hi all,

I wrote small script for Solaris and when I am running it through command prompt its ok, but when I trying to run it using crontab, i am getting error like:

Code:
 
ld.so.1: dbloader: fatal: libACE.so: open failed: No such file or directory
/tmp/file.sh: line 5:  8304 Killed                  /fullpath/script /using/some/directory > /tmp/output.hc

script usin some input parameters and one of this is -/using/some/directory

Could someone help me to find out what is the problem ca be... May be I have to define some path for PATH variable (if so - in /etc/profile or $HOME_DIR/.profile and which path)?

Thanks in advance,
Regard,
Roman

Last edited by zaxxon; 10-27-2009 at 05:35 AM.. Reason: code tags please!
# 2  
Environments are not automatically active in cronjobs, ie. you have to make sure that environment files like .profile etc. are sourced/used explicitly. It's often better to use absolute paths etc. since PATH will be different than when being logged in with a user.
These problems occure often so have a look at this maybe too:
https://www.unix.com/answers-frequent...n-crontab.html
# 3  
Hi, thanks for replies.

zaxxon, thanks for link it is very interesting.

But unfortunatelly, problem still exist... (((

My test script is:
Code:
bash-3.00$ more spots_dhc.sh 
#!/bin/bash 
SPF=/var/opt/spots-pms/traffic_data/ascii/*.spf
echo $SPF > /tmp/output.hc
/opt/spots-pms/bin/dbloader -d / -ei -fi -r /var/opt/spots-pms/traffic_data/ascii/*.spf >> /tmp/output.hc
bash-3.00$

If I am using only name, without full path, i am getting error:
Code:
bash-3.00$ mail
From spots@SPOTS Wed Oct 28 13:08:00 2009
Date: Wed, 28 Oct 2009 13:08:00 +0400 (AZT)
From: SPOTS Administrator <spots@SPOTS>
Message-Id: <200910280908.n9S980ii014185@SPOTS>
To: spots@SPOTS
Subject: Output from "cron" command
Content-Length: 132
Your "cron" job on SPOTS
/tmp/spots_dhc.sh
produced the following output:
/tmp/spots_dhc.sh: line 4: dbloader: command not found

? dp
bash-3.00$

But if I am using full path in script, then i am getting error:
Code:
bash-3.00$ mail
From spots@SPOTS Wed Oct 28 12:57:00 2009
Date: Wed, 28 Oct 2009 12:57:00 +0400 (AZT)
From: SPOTS Administrator <spots@SPOTS>
Message-Id: <200910280857.n9S8v0x8013564@SPOTS>
To: spots@SPOTS
Subject: Output from "cron" command
Content-Length: 315
Your "cron" job on SPOTS
/tmp/spots_dhc.sh
produced the following output:
ld.so.1: dbloader: fatal: libACE.so: open failed: No such file or directory
/tmp/spots_dhc.sh: line 4: 13560 Killed                  /opt/spots-pms/bin/dbloader -d / -ei -fi -r /var/opt/spots-pms/traffic_data/ascii/*.spf >>/tmp/output.hc

Which directory or file not exist? I was trying to define PATH - opt/spots-pms/bin/ in /etc/default/cron, but same result...
And again if i am running from command line its ok.

Last edited by pludi; 10-28-2009 at 07:39 AM.. Reason: code tags, please...
# 4  
Full path looks better than without. Make sure that you have the same environment like when you start it on the command line.

Code:
ld.so.1: dbloader: fatal: libACE.so: open failed: No such file or directory

... looks to me as if there is still some variable that contains a path to some libraries is not set when being executed via cron.

Check the original environment of that user with the command env and set and do same with your script being fired off via cron and compare if there is some obvious looking variable is not set.

Make sure that this script/cronjob sources the .profile and any other needed environment files.

Last edited by zaxxon; 10-28-2009 at 09:51 AM.. Reason: added info
# 5  
Further to zaxxon. A agree, you are probably missing an environment variable which points to a Library Path.
To see the difference in environments:
Write a small script containing just your shebang and a "set" command and an "env" command.
1) Submit the script as an "at" job from your normal prompt.
2) Submit the script as a "cron" job.
3) Compare the output.
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #238
Difficulty: Easy
Steve Jobs was the first to build a theoretical model for communication using packet switching.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

CRONTAB - one python script is not running

Hi! I'm using a RaspberryPi with standard Raspbian. Currently I'm working on some sort of weather station. For now I have three python scripts - one which is updating txt files for website - update1m.py ( it will not be necessary in few next days so I'll delete it) , second one for updating... (4 Replies)
Discussion started by: bartocham
4 Replies

2. Solaris

Script problem when running on crontab

Hi guys! I created a backup script that works fine when I run manually, but when I put a crontab job to execute it the result are not the expected. (not a time problem). Here is my script: bash-3.00# cat /bk_tool/backup2.sh #!/usr/bin/csh clear set DIR_HOST='SCP08' ... (3 Replies)
Discussion started by: andredemartini
3 Replies

3. UNIX for Advanced & Expert Users

Error while running Rsync through Crontab

hi All, i have implemented Rsync in my source and destination server. while running through command prompt it is working fine: ksh rsync_bravo_db.ksh usa0300uz1252.apps.mc.xerox.com /uv1402/u207/home/bravodba/bin/rsync-3.0.9/config/mrsx_rsync.cfg but later on i created a another ksh and... (4 Replies)
Discussion started by: lovelysethii
4 Replies

4. UNIX for Dummies Questions & Answers

crontab not running script

Hi All, I am having the below script to be run from crontab, it it doesnt run. 1 * * * * /home/cobr_ext/test.sh > /home/cobr_ext/temp.txt when i run i manally it runs without any issues. Could please help me as to why doesnt it run the script.:( (7 Replies)
Discussion started by: abhi_123
7 Replies

5. UNIX for Advanced & Expert Users

Particular script not running through crontab

Hi, I have created the below script, set -x # Set the Path of Environment file ENV_FILE_DIR=/opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/bin LOG_DIR=/opt/app/p1trp1c1/sybase/ecdwqdm/xrbid/QDM_Prod/log export ENV_FILE_DIR export LOG_DIR # Set Audit Environment . ${ENV_FILE_DIR}/QDM.env... (8 Replies)
Discussion started by: yohasini
8 Replies

6. Shell Programming and Scripting

Crontab not running a script

Hi, I posted this in the Solaris forum but I think this one would be more appropriate. I created a script starting with the following lines: #!/usr/bin/ksh flag=n export flag typeset -i quant=0 (...) When running it I'm getting the following 2 errors: /tmp/tstscript/testfail.ksh:... (9 Replies)
Discussion started by: Cvg
9 Replies

7. Shell Programming and Scripting

Running SQLPLUS Script in CRONTAB

Hi, Can someone please help me here with this one. This is my script: # more tosh.sh #!/usr/bin/ksh clear . /home/oracle/.profile echo "Good morning, world." export ORACLE_HOME=/u01/app/oracle/product/9.0.1 export PATH=$ORACLE_HOME/bin:/usr/local/bin export ORACLE_SID=xxxx ... (11 Replies)
Discussion started by: santoshpayal
11 Replies

8. Shell Programming and Scripting

Problem with crontab running a script

I am trying to use the CRON utility in Fedora 11 & CentOS... I intend to run a script which pops up a warning message every hour and i made the following entry using "CRONTAB -e " * * * * * sh /bin/myscript.sh But this does not seem to be running. Another thing to note is that,... (4 Replies)
Discussion started by: Vabiosis
4 Replies

9. Red Hat

Problems with script running with crontab

Hi, I'm trying the backup a few information commands of my Check Point FW (it's on a SPLAT linux machine). This is the script I wrote: #!/bin/bash cd /var/tmp/ file1=netstat_`/bin/date +%d%m%y`.txt file2=ifconfig_`/bin/date +%d%m%y`.txt file3=cpstatos_`/bin/date +%d%m%y`.txt... (2 Replies)
Discussion started by: nirsh
2 Replies

10. Shell Programming and Scripting

issue with running script with crontab

I am facing a strange issue while running a script(eg A) from the crontab entry the script calls one more script(eg B) within it now when i run the script A manually(with nohup) it also executes the script B (embedded inside it) as expected. but when i run the script A from the crontab entry... (7 Replies)
Discussion started by: mad_man12
7 Replies

Featured Tech Videos