Slackware This Forum is for the discussion of Slackware Linux.
|
| 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. |
|
 |
09-19-2008, 06:44 AM
|
#1
|
|
Member
Registered: Sep 2008
Location: Middle of Nowhere, England
Distribution: Slackware 13.1, Ubuntu 10.10
Posts: 38
Rep:
|
Get KDE program to run permanently.
Hi everyone, new member here.
I am trying to make a program run more reliably by making it restart if it closes (through crash or pressing the close button).
I have tried using BASH "while true" loops but haven't really had any success.
If anybody can think of any way this could be done. Preferably BASH or something in xinit, but I could use python or perl if necessary.
I'm using KDE 3.5 (if that makes a difference)
Anyway... If anybody can help at all I would be most grateful.
Thanks to any and everybody in advance!
X-T
|
|
|
|
09-19-2008, 09:27 AM
|
#2
|
|
Senior Member
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 1,853
|
try monit. Hope it suit your needs
|
|
|
|
09-19-2008, 09:57 AM
|
#3
|
|
Member
Registered: Sep 2008
Location: Middle of Nowhere, England
Distribution: Slackware 13.1, Ubuntu 10.10
Posts: 38
Original Poster
Rep:
|
Thanks!
Awesome! Looks like just what I need! Thanks for your speedy reply, your help is much, much appreciated!
X-T
|
|
|
|
09-19-2008, 10:15 AM
|
#4
|
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,565
|
Just for the record, why doesn't the while loop work for you? I've used it before myself with unstable programs, such as once when there was a bug in ktorrent that made it crash occasionally on my system. In that case I only had to do one other thing to make it work, and that was run it with the --nofork and --nocrashhandler options to keep it from launching as a background process and popping up the crash report dialog every time.
|
|
|
|
09-22-2008, 08:52 AM
|
#5
|
|
Member
Registered: Sep 2008
Location: Middle of Nowhere, England
Distribution: Slackware 13.1, Ubuntu 10.10
Posts: 38
Original Poster
Rep:
|
Hi guys... Thanks for all your support... I've actually fixed my while loop. I was being an idiot and forgetting where I needed to put semicolons. Also a less pretty, but smaller (by a whole line of code  ) way of doing it would be to do this:
Code:
#!/bin/bash
/path/to/program
/path/to/this/script
Anyway... Thanks again for everybody's help, and I hope that my membership will continue to be as enjoyable as this!
X-T
Last edited by xtothat; 09-22-2008 at 08:53 AM.
Reason: My smiley looked all wrong!
|
|
|
|
09-22-2008, 08:59 AM
|
#6
|
|
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 3,965
|
Quote:
Originally Posted by xtothat
Hi guys... Thanks for all your support... I've actually fixed my while loop. I was being an idiot and forgetting where I needed to put semicolons. Also a less pretty, but smaller (by a whole line of code  ) way of doing it would be to do this:
Code:
#!/bin/bash
/path/to/program
/path/to/this/script
Anyway... Thanks again for everybody's help, and I hope that my membership will continue to be as enjoyable as this!
X-T
|
The bad thing about this alternate way is that bash instances will pile up. Each time you call the script a new bash session is opened, and they will live forever, filling your ram.
That's not a problem if it crashes a couple of time, but it's a big problem if it happens a few dozen times. So, I'd use the while loop instead.
|
|
|
|
09-22-2008, 09:19 AM
|
#7
|
|
Member
Registered: Sep 2008
Location: Middle of Nowhere, England
Distribution: Slackware 13.1, Ubuntu 10.10
Posts: 38
Original Poster
Rep:
|
I'm learning something new every post. I'll go with the while loop. Thanks!!!
|
|
|
|
09-22-2008, 10:06 AM
|
#8
|
|
Member
Registered: Apr 2005
Location: Havant, Hampshire, UK
Distribution: Slamd64, Slackware, PS2Linux
Posts: 465
Rep:
|
Code:
#!/bin/bash
/path/to/program
exec /path/to/this/script
Should keep the number of instances down to exactly one, since instead of spawning a new instance, it'll just reuse the same one (or more accurately, replace whatever spawned it) ...
I hope 
|
|
|
|
09-23-2008, 05:20 AM
|
#9
|
|
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 3,965
|
Quote:
Originally Posted by piete
Code:
#!/bin/bash
/path/to/program
exec /path/to/this/script
Should keep the number of instances down to exactly one, since instead of spawning a new instance, it'll just reuse the same one (or more accurately, replace whatever spawned it) ...
I hope 
|
Yes, that's correct as well.
|
|
|
|
09-26-2008, 12:56 PM
|
#10
|
|
Member
Registered: Sep 2008
Location: Middle of Nowhere, England
Distribution: Slackware 13.1, Ubuntu 10.10
Posts: 38
Original Poster
Rep:
|
Cool! Thanks!
|
|
|
|
| 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 12:01 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
|
|