If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > script not found when run on cron

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-07-03, 13:30
mixxalot mixxalot is offline
Registered User
 
Join Date: May 2003
Posts: 369
script not found when run on cron

Hello folks,

I have a DB2 ksh script running from a cron job and it fails to run correctly. We run it on AIX 5.2 32 bit using DB2 UDB 7.2 and receive the following error message:


/home/script.ksh[64]: db2: not found.
Interactive mode off.
Local directory now /export
257 "/export" is current directory.
netout: write returned 0?
netout: write returned 0?
netout: write returned 0?


************************************************** ***************
cron: The previous message is the standard output
and standard error of one of the cron commands.

Here is the crontab setup: to run every 15 minutes:


# crontab -l
00,15,30,45 03-20 * * * /home/script.ksh


Funny thing is that when I run the db2 script manually it works fine without problems. How can I fix this to get it to run in cron? Thanks!

Scott
Reply With Quote
  #2 (permalink)  
Old 10-07-03, 14:58
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Re: script not found when run on cron

Quote:
Originally posted by mixxalot

I have a DB2 ksh script running from a cron job and it fails to run correctly. We run it on AIX 5.2 32 bit using DB2 UDB 7.2 and receive the following error message:


/home/script.ksh[64]: db2: not found.
cron daemon does not execute the profile for you when it spawns a shell to run your script. As a result your DB2 environment (PATH, DB2INSTANCE, DB2COMM etc) is not set.

You have to execute profile explicitly from your script before attempting to run db2
Reply With Quote
  #3 (permalink)  
Old 10-07-03, 16:25
dbamota dbamota is offline
Registered User
 
Join Date: Sep 2003
Posts: 237
Try # crontab -l
00,15,30,45 03-20 * * * su - urnam -c "/home/script.ksh"
where urnam is the userid with which you are able to run the script in interactive mode.This from the root's crontab. It switches to user urnam,
establishing the right ENVironment; in particular PATH, and the DB2 variables.
__________________
mota
Reply With Quote
  #4 (permalink)  
Old 10-07-03, 17:56
mixxalot mixxalot is offline
Registered User
 
Join Date: May 2003
Posts: 369
how do I configure the profile?

Sorry my Unix sysadmin skills are rusty. How would I configure my profile settings for db2inst1 to run the cron job scheduled script ?

Thanks!

Scott
Reply With Quote
  #5 (permalink)  
Old 10-07-03, 22:01
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Re: how do I configure the profile?

Quote:
Originally posted by mixxalot
Sorry my Unix sysadmin skills are rusty. How would I configure my profile settings for db2inst1 to run the cron job scheduled script ?

Thanks!

Scott
You should have the db2 profile settings in the standard user profile, /home/db2inst1/.profile in your case. You could insert the following into your script

# check if db2 env. set
if [ "$DBINSTANCE" = "" ]; then
# not set; run profile
. /home/db2inst1/.profile
fi

Alternatively, there should be a db2profile script in the instance's home directory. You could run it instead.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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