Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


Search this Thread
Old 09-22-2010, 03:11 AM   #1
Registered: Nov 2009
Posts: 94

Rep: Reputation: 15
script to test if a program is running

i'm trying to test whether wget is working still or not.

while [ wget is still running ] <----- but how should this look please.?
Old 09-22-2010, 04:05 AM   #2
LQ Newbie
Registered: Sep 2010
Posts: 21

Rep: Reputation: 0
I am new to Linux but I think this will help:
There is a directory in Linux called /proc that keeps all running processes information. You can find out if wget is running or not by searching for it in running processes list.
getProcessID() will perform this search for you, all you need is to supply it with the wget process name. You can find a sample code here:

Old 09-22-2010, 04:43 AM   #3
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
You can check with: 'pidof wget', 'pgrep wget', ...
1 members found this post helpful.
Old 09-22-2010, 05:42 AM   #4
Registered: Aug 2010
Distribution: Fedora, Centos, Debian
Posts: 49

Rep: Reputation: 7
server:~# ps axu | grep -c wge[t]
So you can simply use if/then/else to do what you need.


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 do I test whether network-script is running or not in Xen Dom0. tkmsr Linux - Virtualization and Cloud 1 04-10-2010 07:03 PM
running a C program from shell script jkeertir Linux - Newbie 3 05-19-2008 05:05 AM
See if a program is already running in a script tytower Linux - Desktop 6 01-27-2007 01:26 AM
Running shell script within a C or C++ program Quantum0726 Programming 2 06-15-2005 09:14 PM
Problem running ATI driver test script chrisjbzero Linux - Newbie 1 03-28-2004 03:23 PM

All times are GMT -5. The time now is 08:51 AM.

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 @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration