LinuxQuestions.org
Register a domain and help support LQ
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-01-2005, 04:20 PM   #1
garba
Member
 
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, 04:47 PM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,790
Blog Entries: 1

Rep: Reputation: 414Reputation: 414Reputation: 414Reputation: 414Reputation: 414
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, 04:50 PM   #3
Brian1
Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 61
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 & '

Brian1
 
Old 05-01-2005, 05:11 PM   #4
garba
Member
 
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, 05:25 PM   #5
perfect_circle
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, 07:31 PM   #6
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,783

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
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, 11:30 AM   #7
garba
Member
 
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
 
  


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


All times are GMT -5. The time now is 06:29 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration