The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Identifying and grouping OS processes and APP processes wilsonee SUN Solaris 2 09-30-2008 10:26 AM
Monitoring Processes - Killing hung processes ukndoit UNIX for Advanced & Expert Users 4 01-17-2008 04:30 AM
Help with counting files please gerard1 Shell Programming and Scripting 6 09-25-2006 02:37 PM
counting characters plelie2 Shell Programming and Scripting 6 02-25-2003 01:38 PM
Counting LOC in C amatsaka High Level Programming 1 06-04-2002 04:18 PM

Closed Thread
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 03-21-2007
heprox heprox is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 32
Counting Processes

I have a simple script that I want to notify me whenever there are anything other than one instance of a particular process running. I've always used the script:

Code:
DPID_DW=$(ps -ef | grep [d][w] | wc -l)
if [ "${DPID_DW}" -eq 0 ]
   then
        echo "The data warehouse manager for DB is down"
elif [ "${DPID_DW}" -gt 1 ]
  then
        echo "More than one instance of the DW Manager is running"
fi

,,,the problem is that the process is more than a single line. It looks like:


Code:
ps -ef | grep [d][w]
  genret 156098      1   0   Mar 19      - 167:25 /prod/jre_1.3.1/sh/java -Dprgi
d=DWManager -Xms1m -Xmx1024m -Djava.security.policy=/gers/genret/.java.policy -D
xml.catalog.files=/gers/catalog/catalog -cp /gers/genret/opt/path/gerscs.jar:/ge
rs/genret/opt/path/gersdw.jar:/gers/genret/jdbc/lib/classes12.zip:/gers/genret/m
enu/pub/sbin:/gers/genret/menu/pub/bin:/gers/genret/menu/pub/mac:/gers/genret/me
nu/adm/sbin:/gers/genret/menu/adm/bin:/gers/genret/menu/adm/mac:/gers/genret/men
u/sup/bin:/gers/genret/menu/sup/mac:/gers/genret/custom:/gers/genret/fix:/gers/g
enret/src_rev/fix:/gers/genret/opt/path:/gers/genret/bin:/g/bin:/usr/bin:/etc:/u
sr/sbin:/usr/ucb:/sbin -DVERBOSE=n com.gers.dw.DWManager

  #2 (permalink)  
Old 03-21-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Er, you should confirm that. The output is spread across multiple lines on screen, but if you check with wc -l or grep -c, you will find that it is on a single line.
  #3 (permalink)  
Old 03-21-2007
heprox heprox is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 32
I thought the same thing, but I always get "echo "More than one instance of the DW Manager is running" message? Indicating that it is counting more than one line....
  #4 (permalink)  
Old 03-21-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Can you actually do an echo of DPID_DW and check the value stored there?
  #5 (permalink)  
Old 03-21-2007
heprox heprox is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 32
I comes back as "2"?


Code:
x-4-1-user# dw_test
       2
x-4-1-user#

Closed Thread

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 09:45 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