LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 02-21-2008, 12:03 PM   #1
ratul_11
LQ Newbie
 
Registered: Dec 2005
Posts: 29

Rep: Reputation: 15
PROCESS CHECKING USING PIDs


Dear All
If i want to check a process is running or not by using PIDs. Like
ps -ef | grep -v grep| grep httpd but here I dont want to use any service name( like httpd or mysqld) I only want to use pid like this

ps -ef | grep -v grep| grep 2180 .But one problem I am facing using this if there is some process of PID 12( And I want to get output for the process with PID 12) and some process with PID 5612 but using the command syntax ps -ef | grep -v grep| grep 12 is printing all process containg digit 12 in their PIDs. How to solve this problem ?

Thanks&Regards in advance
Anirban Adhikary.
 
Old 02-21-2008, 12:43 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by ratul_11 View Post
ps -ef | grep -v grep| grep httpd
'pgrep' can return PIDs, could use 'pgrep -f httpd >/dev/null 2>&1 && echo running'.
And please don't use all caps for thread titles. No need to shout.
 
Old 02-21-2008, 02:08 PM   #3
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Also, checking a PID can change on occasion, if you're wanting to use this to ensure a particular service is running, I wouldn't recommend this way of checking. And like unspawn suggested, another alternative is to use the pidof command to find the PID's of a particular service.

# pidof httpd
17141 9356 9355 9354 9353 9352 9351 9350 9349
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Process Checking Command ratul_11 Linux - General 2 12-26-2007 06:52 AM
Perl Process Checking Problem ratul_11 Programming 5 10-08-2007 04:22 AM
System Hung Process Checking ahpin Linux - Server 2 08-15-2006 01:27 AM
checking for a Process reygudu Programming 3 11-21-2005 04:13 AM
Process and thread PIDs msriram_linux Programming 4 11-27-2004 11:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 08:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration