![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to check if a process is running in a server from shell script. | debu | UNIX for Advanced & Expert Users | 2 | 01-24-2008 02:19 PM |
| check process running | rose1207 | Shell Programming and Scripting | 4 | 12-27-2007 10:23 PM |
| script to check for a particular process and alert if its not running | goks | Shell Programming and Scripting | 1 | 12-09-2005 02:11 AM |
| How to check if another instance of the process is running | sim | Shell Programming and Scripting | 8 | 06-30-2005 04:24 AM |
| check my code?? running shell from c? | abdul | UNIX for Dummies Questions & Answers | 1 | 09-03-2001 12:05 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to check for specific process running through shell
Hi
I want to check whether specific process is running or not through a shell script. ps -ef | grep will tell me this, i tried this way in shell cnt =`ps -ef| grep xyz | awk '{ END {print NR}}` if it return two rows, job is running else not. Is there any better way of doing this. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
How about using grep twice over? If you wanted to check if inetd was running, you could use:
Code:
ps -ef | grep inetd | grep -vc grep |
|
#3
|
||||
|
||||
|
Why two rows ?
Try this Code:
cnt=$(ps -ef | grep -c '[x]yz') |
|
#4
|
||||
|
||||
|
Quote:
|
||||
| Google The UNIX and Linux Forums |