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
Monitoring a single process in solaris jayana SUN Solaris 3 05-31-2008 03:35 AM
Monitoring for a hung process prismtx Shell Programming and Scripting 2 03-08-2008 09:31 AM
monitoring process list via snmp, hrSWRun Bzubi AIX 0 10-18-2007 05:43 AM
Process Monitoring Script Help rdc69 Shell Programming and Scripting 0 08-30-2006 07:55 PM
Monitoring ftp process arkhewit UNIX for Dummies Questions & Answers 2 06-29-2005 07:56 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 10-11-2007
eric_wong_ch eric_wong_ch is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 10
[Solved] process monitoring

hi all,

i would like to write the shell script to monitoring the processing, but if i passing the parameter the number of process is incorrect
how to slove it? many thx

got the correct number of process as following script:
===========================================================
#!/bin/sh

isRunning=`ps -ef | grep -v grep | grep processName.sh | wc -l`
if [ $isRunning -eq 1 ]
then
echo "running"
else
echo "not running"
fi
===========================================================


got the incorrect number of process if passing param
===========================================================
#!/bin/sh

isRunning=`ps -ef | grep -v grep | grep $1 | wc -l`
isRunning=`ps -ef | grep -v grep | grep "$1" | wc -l` <-- other way
if [ $isRunning -eq 1 ]
then
echo "running"
else
echo "not running"
fi
===========================================================

Last edited by eric_wong_ch; 10-11-2007 at 07:09 AM..
  #2 (permalink)  
Old 10-11-2007
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
can you please post o/p of "ps -ef | grep your_shellscript" ???
  #3 (permalink)  
Old 10-11-2007
eric_wong_ch eric_wong_ch is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 10
sure~~

command: ps -ef | grep nonstop.pl
root 6565 5858 99 15:27 pts/7 00:00:33 perl nonstop.pl
root 6587 5900 0 15:28 pts/9 00:00:00 grep nonstop.pl
  #4 (permalink)  
Old 10-11-2007
eric_wong_ch eric_wong_ch is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 10
problem solved

isRunning=`ps -ef | grep -v $0 | grep -v grep | grep $1 | wc -l`

should be skip the monitoring script itself by "grep $0"
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:07 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