LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 12-24-2005, 02:01 AM   #1
walwali
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?

Thanks.
 
Old 12-24-2005, 03:48 AM   #2
DarkElf109
Member
 
Registered: Dec 2005
Location: Phoenix, AZ
Distribution: Ubuntu, Debian, Gentoo
Posts: 43

Rep: Reputation: 15
Code:
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, 02:39 PM   #3
walwali
LQ Newbie
 
Registered: Jun 2005
Posts: 7

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


Reply


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 08:15 PM
a script for process lof file to find online user netman_af Linux - Networking 1 08-17-2004 10:18 AM
script to check if process is dead or running rspurlock *BSD 6 04-13-2004 12:32 AM
ghost-xmms: alive, but dead? b0uncer Linux - Software 5 01-04-2004 08:36 AM
upgrade advice wanted - dead or, well, no, alive is better adam_edam Linux - Hardware 1 05-10-2003 06:10 PM


All times are GMT -5. The time now is 01:45 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration