LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 09-22-2010, 03:11 AM   #1
turf
Member
 
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.?
do
codes
done
 
Old 09-22-2010, 04:05 AM   #2
moby@root
LQ Newbie
 
Registered: Sep 2010
Posts: 21

Rep: Reputation: 0
Hi,
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: http://programming-in-linux.blogspot...name-in-c.html

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

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

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


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
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

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

All times are GMT -5. The time now is 02:47 AM.

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