The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
issue with running script with crontab mad_man12 Shell Programming and Scripting 7 08-27-2009 04:12 AM
A command in a script not running in Crontab. mystition UNIX for Dummies Questions & Answers 2 07-02-2009 04:59 AM
Script not running properly when run from Crontab simoncjones Shell Programming and Scripting 2 05-03-2009 03:11 PM
problem running shell script (for oracle export) in crontab jsheehan223 Shell Programming and Scripting 1 10-16-2008 04:29 PM
Facing issue in Solaris OS in crontab for running shell script mabrar Shell Programming and Scripting 2 11-02-2007 06:32 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-27-2009
nypreH nypreH is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 6
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 03:35 AM.. Reason: code tags please!
  #2 (permalink)  
Old 10-27-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,323
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:
cron and crontab
  #3 (permalink)  
Old 10-28-2009
nypreH nypreH is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 6
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 05:39 AM.. Reason: code tags, please...
  #4 (permalink)  
Old 10-28-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,323
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 07:51 AM.. Reason: added info
  #5 (permalink)  
Old 10-28-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,184
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.
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0