Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 12-24-2005, 01:01 AM   #1
LQ Newbie
Registered: Jun 2005
Posts: 7

Rep: Reputation: 0
Question How to find out whether a process is dead or alive from within a shell script file

I am writing a shell script to a file. The script -after somehow being provided with a process id- should kill it after determining that the process is up and running. I need to a way to silently (i.e, without printing output to the standard output) determines whether the process is running or not... I looked up the man page for ps but did not see any option/flag that would allow this silently... Anybody knows of a way?

Old 12-24-2005, 02:48 AM   #2
Registered: Dec 2005
Location: Phoenix, AZ
Distribution: Ubuntu, Debian, Gentoo
Posts: 43

Rep: Reputation: 15
ps -A | grep -q <process ID>

if [ $? -eq 0 ]
I'm using that in a script, and I don't get any output, whether the process exists or not.
Old 12-24-2005, 01:39 PM   #3
LQ Newbie
Registered: Jun 2005
Posts: 7

Original Poster
Rep: Reputation: 0
That worked. Thanks DarkElf109 for the help.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 07:15 PM
a script for process lof file to find online user netman_af Linux - Networking 1 08-17-2004 09:18 AM
script to check if process is dead or running rspurlock *BSD 6 04-12-2004 11:32 PM
ghost-xmms: alive, but dead? b0uncer Linux - Software 5 01-04-2004 07:36 AM
upgrade advice wanted - dead or, well, no, alive is better adam_edam Linux - Hardware 1 05-10-2003 05:10 PM

All times are GMT -5. The time now is 07:13 PM.

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