Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-28-2004, 08:43 AM
|
#1
|
|
Member
Registered: Nov 2003
Location: France
Distribution: Gentoo
Posts: 30
Rep:
|
Check if an app is running and if it's not launch this app
Hello,
I have one thing that I Would like to do but I do not know if there is a way to do that or not...
I'd like to check every 5 mins or 10, if a specific app is running and if it's not, I would like to launch it.
Do you think such thing is possible? and if yes, I should look at which programming language??
Thxs in advance
Ludo
|
|
|
|
05-28-2004, 09:54 AM
|
#2
|
|
Member
Registered: Mar 2004
Posts: 519
Rep:
|
Sure sounds very possible, you could get something to run every x minutes using cron, just with multiple crontab entries in the minute field (so run @ 5, 10, 15 ...0).
To check if the program is running, you could try:
ps -A | grep <process> | grep -v grep
and get a shell script to test output for a certain string.
I know that's a bit vague but I think it's a good way to do it of the top of my head, there may be much better ways though that might be suggested by other people.
Maybe if you give us a bit more info on which program you want to run we might be able to help you more :)
Steve
|
|
|
|
05-28-2004, 09:58 AM
|
#3
|
|
Member
Registered: Nov 2003
Location: France
Distribution: Gentoo
Posts: 30
Original Poster
Rep:
|
thxs for the answer
that would be for checking if amule is working or not
Ludo
|
|
|
|
07-28-2008, 02:34 AM
|
#4
|
|
LQ Newbie
Registered: Dec 2007
Posts: 17
Rep:
|
Hi,
pgrp can help you.
Use prep -x <Name of the process>.
Also, You can search for the process name in the /proc/pid/stat. If you find the process name there, you don't need to start the process again otherwise you can start the process again. For starting the process, you can either use fork or system("<process name>").
I believe you can achieve your goal in script as well as after writing a small C program.
cheers,
Micky
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:55 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|