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 > db2diag -A help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-02-12, 14:52
db2_database_user db2_database_user is offline
Registered User
 
Join Date: Aug 2012
Posts: 3
db2diag -A help

I am trying to run db2diag -A filename to archive
db2diag.log in /db2/SID/db2dump folder. It works fine from command
line, but does not work in crontab. I made a script that the crontab will
call. I get a db2 command not found error. I read on forum to add
-readfile option. I need help where to add this option.
My command in the script is
db2diag -A /backup/dump_xxx
this works fine from the command but not in the script, where should I add
the -readfile option.
Thanks a lot for the help.
Reply With Quote
  #2 (permalink)  
Old 08-02-12, 14:56
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 5,085
Make sure that the instance profile ($INSTANCE_HOME/sqllib/db2profile) is executed by cron prior to db2diag. The easiest approach would be to schedule a script similar to this:
Code:
#!/bin/sh
. /home/db2inst1/sqllib/db2profile
db2diag -A
__________________
---
"It does not work" is not a valid problem statement.
Reply With Quote
  #3 (permalink)  
Old 08-02-12, 14:56
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 4,018
My guess is that the first line of you script need to load the DB2 profile:

Code:
. /home/db2inst1/sqllib/db2profile
Andy
Reply With Quote
  #4 (permalink)  
Old 08-02-12, 15:03
db2_database_user db2_database_user is offline
Registered User
 
Join Date: Aug 2012
Posts: 3
info

are you suggesting I add
/db2/db2<SID>/sqllib/db2dump
the physical location as the first line after #!/bin/sh entry
Reply With Quote
  #5 (permalink)  
Old 08-02-12, 15:08
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 4,018
The reason you are getting the command not found error is because your DB2 environment is not set up properly through cron. By loading the profile as the fist line, like we have suggested, this will fix the problem.

Andy
Reply With Quote
  #6 (permalink)  
Old 08-02-12, 15:34
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 5,085
Quote:
Originally Posted by db2_database_user View Post
are you suggesting I add
/db2/db2<SID>/sqllib/db2dump
the physical location as the first line after #!/bin/sh entry
No, this is not at all what I am suggesting. Must be a trick question...
__________________
---
"It does not work" is not a valid problem statement.
Reply With Quote
  #7 (permalink)  
Old 08-02-12, 16:28
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,525
Yes, you need the -readfile option to make it work in cron. This is due to some sadistic IBM programmer who owes 2 weeks of my life back that it took me to figure this out.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #8 (permalink)  
Old 08-02-12, 16:43
db2_database_user db2_database_user is offline
Registered User
 
Join Date: Aug 2012
Posts: 3
-readfile

db2diag -A /directory_name_for_archive_file
where do I put -readfile option
db2diag -A -readfile /directory_name_for_archive_file
because it says after -A option other options are overlooked
Reply With Quote
  #9 (permalink)  
Old 08-02-12, 16:57
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,525
The readfile option has nothing to do with a file name, which is why it is so stupid.

db2diag -level Error,Severe,Critical -H 60m -readfile


This returns all Error,Severe,Critical errors in the last 60 minutes. The doc on this command is pathetic.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #10 (permalink)  
Old 08-29-12, 10:56
KirkTX KirkTX is offline
Registered User
 
Join Date: Aug 2012
Posts: 1
Thanks Marcus - you're absolutely right about the solution. If you're trying to use
db2diag in a script that crontab invokes, use the -readfile parameter. I can't tell you how many variations of running sqllib/db2profile and other things within the script I've tried, but -readfile worked right away.
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