Programming a non blocking delay
I am running Unified Remote Server on a Raspberry Pi and want to programm a non blocking delay. So far I have tried different implementations, however the main problem is that during the delay (sleep phase) URServer is not ready to take other commands. One implementation is:
actions.test= function () os.script("./script1.sh"); os.sleep(60000); os.script("./script2.sh"); end
I have already tried executing the sleep in the scripts using a background worker without success. Input how to implement a non blocking delay is therefore highly appreciated.
You might be able to use a timeout delay...... libs.timer on the local remote..... something like this.....
It could be wrong / incomplete as I am a bit rusty..... and the developer libraries I can no longer find on the UR website !!!!
local task = libs.timer actions.test= function () os.script("./script1.sh"); -- help.. run script 2 after delay id = libs.timer.timeout (function() os.script("./script2.sh" ); end, 60000);
Thanks whale-av using a timer solved my problem. If someone needs it, below is the code for a 10 seconds non blocking delay:
local tmr = require("timer"); actions.test= function () os.script("./script1.sh"); tid = tmr.timeout(function() os.script("/script2.sh"); end, 10000); end