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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-28-2004, 09: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, 10: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, 10: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, 03: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
|
|
|
All times are GMT -5. The time now is 08:02 AM.
|
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
|
|