LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 05-28-2004, 09:43 AM   #1
Coume
Member
 
Registered: Nov 2003
Location: France
Distribution: Gentoo
Posts: 30

Rep: Reputation: 15
Question 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
 
Old 05-28-2004, 10:54 AM   #2
SBing
Member
 
Registered: Mar 2004
Posts: 519

Rep: Reputation: 35
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
 
Old 05-28-2004, 10:58 AM   #3
Coume
Member
 
Registered: Nov 2003
Location: France
Distribution: Gentoo
Posts: 30

Original Poster
Rep: Reputation: 15
thxs for the answer

that would be for checking if amule is working or not

Ludo
 
Old 07-28-2008, 03:34 AM   #4
Micky_123
LQ Newbie
 
Registered: Dec 2007
Posts: 17

Rep: Reputation: 0
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
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to launch an app in terminal, & keep it running after I close terminal? kornerr Linux - General 7 06-24-2006 06:54 PM
Is there a way to launch an app so that it's not shown on the taskbar kornerr Linux - General 13 05-17-2005 11:38 PM
app launch speed newby101 Linux - General 3 11-27-2003 01:01 PM
can't launch java app from shell script... LonAllen Linux - Newbie 0 07-07-2003 09:37 AM
lines remaining when I launch an app or terminal spiteres Linux - General 0 05-27-2003 07:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:02 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