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 > How to check if db2 is up and running?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Feb 2004
Posts: 2
How to check if db2 is up and running?

Hi,
I need to test if db2 (version 8.1) is already started using a script, but I actually don't know anything about the databases already created on it (it is still possible than no database is present at all).
Is there a solution other than to create a test database and then drop it?
Thank you
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Jul 2003
Location: Austin, TX, USA
Posts: 278
Commands

Hi,

Please let us know what your operating system is.

Just login to the db2 command window (start-->run-->db2cmd) and execute the following command.

db2 list database directory.

This will list all the databases under the instance.

The windows option is to see whether the db2 services are running under the services option of the db2 control panel. If it is running that means the instance is started.

HTH

Nitin
__________________
HTH

Nitin

Ask the experienced rather than the learned
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Feb 2004
Posts: 2
Re: Commands

Hi, tks for your quick reply.
Unfortunately I need to check on various operating systems (including W2000, Linux, AIX, Solaris, HP-UX).

The "db2 list db directory" commands works even if db2 is stopped, and moreover if no database is present, it returns an empty list.
I need a command (or a script) that returns a different errorlevel/exitcode if the instance is running or not.

I need this as a "precheck" in order to determine if ahould try to create my own database or not.

Hope this clarify.
Tks
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Jul 2003
Location: Austin, TX, USA
Posts: 278
db2start

Hi,

The simplest is..

db2start.

When you fire this command and the instance is running, you will get the message below else the instance will be started.

C:\Documents and Settings\nmaker>db2start
02-20-2004 17:52:00 0 0 SQL1026N The database manager is already active
.
SQL1026N The database manager is already active.

This works on all platforms.

HTH

Nitin.
__________________
HTH

Nitin

Ask the experienced rather than the learned
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
Join Date: Feb 2004
Location: Germany
Posts: 15
Re: How to check if db2 is up and running?

Hi,

another way is to use the netstat command with the option -a . this command lists all TCP/IP connections you'd then look for the instance name or/and the db2 server port.

kirna

Quote:
Originally posted by jason512
Hi,
I need to test if db2 (version 8.1) is already started using a script, but I actually don't know anything about the databases already created on it (it is still possible than no database is present at all).
Is there a solution other than to create a test database and then drop it?
Thank you
Reply With Quote
  #6 (permalink)  
Old
Registered User
 
Join Date: Sep 2003
Location: canada
Posts: 230
Re: How to check if db2 is up and running?

Quote:
Originally posted by kirna
Hi,

another way is to use the netstat command with the option -a . this command lists all TCP/IP connections you'd then look for the instance name or/and the db2 server port.

kirna
another way is toy use

ps -eaf|grep -i db2sysc


if you get db2sysc then instance is up

Thanks
Reply With Quote
  #7 (permalink)  
Old
Registered User
 
Join Date: Sep 2003
Posts: 237
On UNIX, in V8 or V7 FP5 or later
db2_local_ps|wc -l will give number of instance related processes, if you execute the command as instance owner. Your script should check if the number generated is greater than 0 OR not equal to 0 to verify instance is UP
__________________
mota
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