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 > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Getting error while scheduling a script thru cron

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-10-08, 16:36
tudaykumar tudaykumar is offline
Registered User
 
Join Date: Nov 2007
Posts: 26
Getting error while scheduling a script thru cron

Hi all,

I am trying to schedule a script thru cron and i am getting the error

produced the following output:
/export/home/db2inst1/utility/reorg.sh: ~db2inst1/sqllib/db2profile: not found

When I execute the script individually its working perfect, but when thru cron its giving me error

There are already 4 scripts scheduled thru cron and they are working perfect,
but when I added the new one to the list its erroring me out only for this script.

Can someone help me please, thank u all in advance.
Reply With Quote
  #2 (permalink)  
Old 03-11-08, 01:50
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Your .profile is not executed when running cron jobs
You must set your environment in your script
e.g.
. .profile # a space between the . and .
Reply With Quote
  #3 (permalink)  
Old 03-11-08, 02:46
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Could you show us the content of your reorg.sh script?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 03-11-08, 09:47
tudaykumar tudaykumar is offline
Registered User
 
Join Date: Nov 2007
Posts: 26
But there are other scripts scheduled thru cron and they are working fine.
Reply With Quote
  #5 (permalink)  
Old 03-11-08, 09:51
tudaykumar tudaykumar is offline
Registered User
 
Join Date: Nov 2007
Posts: 26
Stolze the script is like this. As I said it works fine when I execute it alone.

#!/bin/ksh
. ~db2inst1/sqllib/db2profile

DIR=/export/home/db2inst1/utility
DATE='date'

db2 "connect to capprddb";

db2 "select substr('reorg table '||rtrim(t.tabschema)||'.'||t.tabname||' index '||rtrim(indschema)||'.'||indname||' use tempspace1;'
,1,125) from syscat.indexes i, syscat.tables t where i.tabname =t.tabname and t.type ='T' and (indextype='CLUS' or uniquerule='U' o
r uniquerule='P') order by t.tabschema, t.tabname" > $DIR/reorg.out;

sed -e '1,2d' $DIR/reorg.out > $DIR/reorg.log;

rm $DIR/reorg.out

db2 -tvf $DIR/reorg.log > $DIR/reorg_report.txt

cat $DIR/reorg_report.txt | mailx -s "Reorg Cap One UAT" xxx@xxx.com

db2 connect reset;


Thank you all
Reply With Quote
  #6 (permalink)  
Old 03-11-08, 11:55
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Do the other scripts also source the db2profile? If they do, you have probably some sort of strange character in your script (what does a hexdump show?).

You can also try replacing "~db2inst1" with "/export/home/db2inst1". Since you hardcode the directory a couple lines below anyway, I don't see any point in trying to be more flexible in the 2nd line.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 03-11-08, 11:55
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Do the other scripts also source the db2profile? If they do, you have probably some sort of strange character in your script (what does a hexdump show?).

You can also try replacing "~db2inst1" with "/export/home/db2inst1". Since you hardcode the directory a couple lines below anyway, I don't see any point in trying to be more flexible in the 2nd line.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #8 (permalink)  
Old 03-11-08, 13:46
tudaykumar tudaykumar is offline
Registered User
 
Join Date: Nov 2007
Posts: 26
Hi Knut, as you said I tried using "/export/home/db2inst1" instead of "~db2inst1" and it worked... Thank you very much.

But how come its working for other scripts using the source db2profile. Any specific reason? And also when you asked me "what does a hexdump show". Where can I find that?

Thank you
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