What's new

RT-AC66U - Excute script every 10 seconds

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

SaSa

New Around Here
*newbie alert*

I followed a guide for setting up a virtual presence sensor. The scripts, called "CheckIfHome" look for a specific MAC address connected to a router and reports to a smarthouse controller. The scripts it self is working well when I execute it manually trough Putty. The script is in the folder /jffs/scripts.

Link to the thread where I found the script.
(https://community.smartthings.com/t/release-asuswrt-wifi-presence/37802).

However, I need help to make a script that runs "CheckIfHome" automatically every 10 seconds (or more often). From the thread mentioned above; the author of the script "CheckIfHome" made a script called "init-start". This script will execute "CheckIfHome" every 15 seconds. Unfortunately this is not working well for me. Not idea why.

The init-start script looks like this:

#!/bin/sh
cru a CheckIfHome "* * * * * /jffs/scripts/CheckIfHome"
cru a CheckIfHome15 "* * * * * sleep 15; /jffs/scripts/CheckIfHome"
cru a CheckIfHome30 "* * * * * sleep 30; /jffs/scripts/CheckIfHome"
cru a CheckIfHome45 "* * * * * sleep 45; /jffs/scripts/CheckIfHome"

After rebooting the router and I run the command cru l;

admin@RT-AC68U-FCC0:/tmp/home/root# cru l
* * * * * /jffs/scripts/CheckIfHome #CheckIfHome#
* * * * * sleep 15; /jffs/scripts/CheckIfHome #CheckIfHome15#
* * * * * sleep 30; /jffs/scripts/CheckIfHome #CheckIfHome30#
* * * * * sleep 45; /jffs/scripts/CheckIfHome #CheckIfHome45#
sarwar@RT-AC68U-FCC0:/tmp/home/root#

The sleep command works for my router.

The issue is that instead of "CheckIfHome" is executed every 15 seconds, it's executed every 40-50 seconds. No matter how I modify the "init-start"

Most likely I'm doing some basically wrong. Any help would be highly appreciated.
 
You are making this way more complicated than it needs to be. Have init-start directly run CheckIfHome, and modify CheckIfHome instead to be a continual loop, with a sleep 15 within that loop.
 
You are making this way more complicated than it needs to be. Have init-start directly run CheckIfHome, and modify CheckIfHome instead to be a continual loop, with a sleep 15 within that loop.

Thanks for your reply. Any input how this code should be looking like? Cheers
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top