Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
creat a run a non-stop loop command after booting every 10s?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
pd1986
Guru
Guru


Joined: 19 Feb 2012
Posts: 381
Location: Paris

PostPosted: Sat Aug 23, 2014 4:50 pm    Post subject: creat a run a non-stop loop command after booting every 10s? Reply with quote

In order to control my fan, I have created a shell script to do that where I compare the CPU temperature with the trippoint and control the fan with a non-stop loop command run every 10 second. I just want to run this command just after booting the system. I tried putting it into the /etc/local.d, but it will take the system into the non-stop loop and the booting can't continue. I tried creating a daemon to run "sh command_path". It was the same. Could someone told me how to do it? Thanks
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7071

PostPosted: Sat Aug 23, 2014 5:08 pm    Post subject: Reply with quote

yourscript &

like :
Code:
ls -l / &
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5761

PostPosted: Sat Aug 23, 2014 5:36 pm    Post subject: Reply with quote

/etc/init.d/fancontrol start?
Back to top
View user's profile Send private message
russK
l33t
l33t


Joined: 27 Jun 2006
Posts: 630

PostPosted: Sat Aug 23, 2014 7:50 pm    Post subject: Reply with quote

The July Gentoo Monthly Newsletter had a tip that could be useful for your script:

Their tip (h/t Sven Vermeulen)
Code:
Launching commands in background once (instead of scheduled through cron)

Have sys-process/at installed.
Have /etc/init.d/atd started.

Use things like:
~$ echo "egencache --update --repo=gentoo --jobs=4" | at now + 10 minutes


So perhaps echo the full path of your script and pipe to 'at now', or maybe 'at now + 1 minutes'

http://blogs.gentoo.org/news/2014/08/11/gentoo-monthly-newsletter-july-2014/
Back to top
View user's profile Send private message
pd1986
Guru
Guru


Joined: 19 Feb 2012
Posts: 381
Location: Paris

PostPosted: Sun Aug 24, 2014 12:43 am    Post subject: Reply with quote

krinn wrote:
yourscript &

like :
Code:
ls -l / &


?? I don't understand
Back to top
View user's profile Send private message
pd1986
Guru
Guru


Joined: 19 Feb 2012
Posts: 381
Location: Paris

PostPosted: Sun Aug 24, 2014 12:44 am    Post subject: Reply with quote

Ant P. wrote:
/etc/init.d/fancontrol start?


NO, As I said, if I do this, the system will go into a non-stop loop and never continue to finish the booting.
Back to top
View user's profile Send private message
pd1986
Guru
Guru


Joined: 19 Feb 2012
Posts: 381
Location: Paris

PostPosted: Sun Aug 24, 2014 1:42 am    Post subject: Reply with quote

russK wrote:
The July Gentoo Monthly Newsletter had a tip that could be useful for your script:

Their tip (h/t Sven Vermeulen)
Code:
Launching commands in background once (instead of scheduled through cron)

Have sys-process/at installed.
Have /etc/init.d/atd started.

Use things like:
~$ echo "egencache --update --repo=gentoo --jobs=4" | at now + 10 minutes


So perhaps echo the full path of your script and pipe to 'at now', or maybe 'at now + 1 minutes'

http://blogs.gentoo.org/news/2014/08/11/gentoo-monthly-newsletter-july-2014/


That's works perfectly. Thanks.
By the way, is there a way to start the job in 5 second in using "at"? like
at now +5 seconds ?
Back to top
View user's profile Send private message
russK
l33t
l33t


Joined: 27 Jun 2006
Posts: 630

PostPosted: Sun Aug 24, 2014 2:17 am    Post subject: Reply with quote

Quote:
By the way, is there a way to start the job in 5 second in using "at"? like
at now +5 seconds ?


No, the at command will not increment by seconds, only minute, hour, day, week, month, or year

5 seconds is not much different from 'at now'. The key is to get the script into the background. I believe that's what krinn was trying to show with an ampersand '&'
Back to top
View user's profile Send private message
pd1986
Guru
Guru


Joined: 19 Feb 2012
Posts: 381
Location: Paris

PostPosted: Sun Aug 24, 2014 2:20 am    Post subject: Reply with quote

russK wrote:
Quote:
By the way, is there a way to start the job in 5 second in using "at"? like
at now +5 seconds ?


No, the at command will not increment by seconds, only minute, hour, day, week, month, or year

5 seconds is not much different from 'at now'. The key is to get the script into the background. I believe that's what krinn was trying to show with an ampersand '&'


Thank you so much.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5761

PostPosted: Sun Aug 24, 2014 8:47 pm    Post subject: Reply with quote

pd1986 wrote:
Ant P. wrote:
/etc/init.d/fancontrol start?


NO, As I said, if I do this, the system will go into a non-stop loop and never continue to finish the booting.

Where was that said? I find it very unusual that lm_sensors' pre-existing script would hang anyone's boot process, given that it's installed on thousands of systems. Did you configure fancontrol properly before running it? Does /usr/sbin/fancontrol run manually from the command line work?
Back to top
View user's profile Send private message
pd1986
Guru
Guru


Joined: 19 Feb 2012
Posts: 381
Location: Paris

PostPosted: Mon Aug 25, 2014 1:16 am    Post subject: Reply with quote

Ant P. wrote:
pd1986 wrote:
Ant P. wrote:
/etc/init.d/fancontrol start?


NO, As I said, if I do this, the system will go into a non-stop loop and never continue to finish the booting.

Where was that said? I find it very unusual that lm_sensors' pre-existing script would hang anyone's boot process, given that it's installed on thousands of systems. Did you configure fancontrol properly before running it? Does /usr/sbin/fancontrol run manually from the command line work?


Sorry, I didn't understand what you meant. I thought you mean to run my script in the name of fancontrol. Actually, I have fancontrol. I tried. But when I run pwmconfig, I got there is no pwm-sensors. I don't have any config file, as pwmconfig doesn't recognize my fan so it can't create any config in my laptop. Even lm_sensors doesn't recognize my fan. I only have the CPU temperature, nothing else. But the Fan actually spins. I can control it manually via /sys/class/thermal/***. I don't know why. I don't know how to write the config manually for fancontrol either.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum