I want a script to be triggered every 5 minutes but if hotplug triggered it within 5 minutes wait till 5 minutes are complete.
Create a semaphore file in /tmp, adapt the actions in the script, based on if it exists, or not.
This isn't really an Openwrt question, but generic scripting.
I implemented semaphore file in Auto Adjust WiFi Script [Help Implement new features]
-
Will semaphore file affect when script is triggered by other script ? That is when cronjob script is triggered by DHCP hotplug will cronjob's semaphore be considered ?
-
Should I only use it for one Cronjob or hotplug ? If I use semaphore for both it will be like running every 5 minutes and simple cronjob is enough.
if you make it consider it ...
depends on the strategy.
if you never want to run the script more often than every 5 mins,
let the script sleep 300 sec, and delete the file at the end of the sleep.
always check if the semaphore's there or not, as the 1st action, when the script's executed.
Auto Adjust WiFi Script [Help Implement new features] 's Aim is to turn down when no one is using and turnup asap.
So how to do so that cronjob's semaphore is not considered when triggered by hotplug?
Is there other way to solve the problem ?
if you use the same script, implement a "bypass" param, making it skip the check/ignore the file.
probably, but I'm not going to do the leg work for you.
again this is not openwrt related, but scripting 101.