Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 05-01-2005, 05:20 PM   #1
Registered: May 2005
Location: Italy
Distribution: Crux
Posts: 62

Rep: Reputation: 15
how to implement an endless loop in a rc startup script

Good day! I've just written this nifty little script to control my cpu fan based on its temp and I'd like to have it run on the background and started at boot time... problem is, the script needs to continuosly probe the cpu sensor and this is achieved through a while1do loop... needless to say, this would cause my boot process to get stuck in an endless loop once the script kicks in and prevent other scripts from being loaded up... I am asking you guys how i could possibly run the script, have it run in background, and then continue the boot process ... thanks in advance for your help, regards, andrea
Old 05-01-2005, 05:47 PM   #2
LQ Veteran
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
I don't know if this would do it, but if you use a & after any executable, control is returned as soon as the program is launched. So in your startup file, it would be something like

/path/to/endlessloopprogram &
Old 05-01-2005, 05:50 PM   #3
LQ Guru
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 62
If I understand you correctly you should be able to add the ' & ' after the command to force it to the background.
Example ' /usr/bin/xmms & '

Old 05-01-2005, 06:11 PM   #4
Registered: May 2005
Location: Italy
Distribution: Crux
Posts: 62

Original Poster
Rep: Reputation: 15
thanks A LOT for your swift reply, you made a nOOb happy! have a nice day!
Old 05-01-2005, 06:25 PM   #5
Senior Member
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 52
If you are going to use an endless loop put a sleep 1 or sleep 2 inside the loop, to make it sleep and wake up, once every second or 2.
An endless loop without restrictions will consume all the cpu usage.
Old 05-01-2005, 08:31 PM   #6
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,896

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
You could also investigate how to daemonize the script (make a watchful daemon out of it) which will run in backgound, waiting until some threshold temp is reached, then activate the fan.

The Linux Daemon Writing HOWTO would be a good place to start.
Old 05-03-2005, 12:30 PM   #7
Registered: May 2005
Location: Italy
Distribution: Crux
Posts: 62

Original Poster
Rep: Reputation: 15
yep, i came up with the sleep thing myself, but thanks for pointing it out! Ok, I'll be investigating how to "demonize" my script! Thanks again for your help gentlemen. Andrea


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
Hotplug endless loop AzCoder Ubuntu 4 04-30-2005 02:56 PM
Bizarre endless login loop CelticWhisper Slackware 6 04-06-2005 07:39 PM
Grub stuck in an endless loop. dikadika Linux - General 4 02-27-2005 08:46 PM
Mandrake 10.1 Install endless loop SteveI Mandriva 2 12-30-2004 10:56 AM
HELP- endless loop contrasutra Linux - Software 2 04-26-2003 12:25 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:54 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration