Alex555
Posts: 3
Joined: Wed Jun 05, 2013 7:06 pm

Run a script every 30 seconds

Sat Jun 08, 2013 6:34 pm

Hello everyone,

I have a bluetooth keyboard connected to my Pi, but it keeps disconnecting automatically after a certain amount of seconds. I was wondering if it is possible to make the Pi run a script every 30 seconds to attempt to re-establish connection with the keyboard. Is it possible to do so?

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13100
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Run a script every 30 seconds

Sat Jun 08, 2013 6:40 pm

probably but you should never try to suppress the symptoms, you should rather cure the disease, which most probably is power supply related, or is because the bluetooth radio is too near a transmitter of radio disturbances (the PI board itself).

Alex555
Posts: 3
Joined: Wed Jun 05, 2013 7:06 pm

Re: Run a script every 30 seconds

Sun Jun 09, 2013 8:05 pm

mahjongg wrote:probably but you should never try to suppress the symptoms, you should rather cure the disease, which most probably is power supply related, or is because the bluetooth radio is too near a transmitter of radio disturbances (the PI board itself).
Well, actually the keyboard just disconnects upon inactivity. I have tested everything else. The keyboard will not disconnect while in use and will do after about 5 mins if inactive.

Now, if you could tell me how to run a script on a delay of about 30-60 secs or any other possible solution, I would very much appreciate it :)

sprinkmeier
Posts: 410
Joined: Mon Feb 04, 2013 10:48 am
Contact: Website

Re: Run a script every 30 seconds

Sun Jun 09, 2013 9:35 pm

Code: Select all

$ watch --precise --interval 30 -- ./your/script/goes/here
unlike a simple loop this won't drift if your script takes a few seconds to run.
unlike CRON this won't start multiple copes if your script takes a few minutes to run.

Have fun flattening your keyboard battery :-)

Return to “General programming discussion”