View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 2 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Thu Aug 23, 2007 10:38 am 
Offline
Joined: Sat May 26, 2007 9:51 pm
Posts: 130
What would you all recommend for having very simple scripts run all the time in the background? I wasn't sure if there is a built-in linux functionality that already handles this in a much easier way. And I also wasn't sure how much power is required for the 'SLEEP' command for background processes.

I'll start with my problem, and then go with a proposed solution.

PROBLEM:
I have a joystick that is assigned to /dev/input/js0 upon startup. However, if I happen to disconnect it, it gets reassigned to /dev/input/js1 if there are programs open that 'were' using the joystick. (Note: I switch controllers often between a joystick for emulators, and my guitar hero controller for Frets On Fire). (Another Note: I use QJoyPad which runs in the background, so upon reconnect, it ALWAYS sets to /dev/input/js1.
So I wrote a script that when run, shuts down all programs using the joystick, waits until a joystick is connected, and then starts up all those programs again. However, I'd rather not have to run the script manually upon disconnect, but instead have it start upon boot, and just poll every few seconds if its been disconnected.

PROPOSED SOLUTION(s):
1) Have the script start on boot either through the KDE's autostart folder, or inserting as a service in init.d. The script would poll every few seconds and idle otherwise with the sleep command.
2) Don't poll, but just set a cron job to run every few seconds?

Any recommendations?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 9:23 pm 
Offline
Joined: Sat May 26, 2007 9:51 pm
Posts: 130
UPDATE:

I ended up just writing a script that runs in the background, and starts on boot. I haven't seen any performance loss using some if statements and the SLEEP command every 2 seconds.


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 71 guests


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 post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu