Hi
Here is my small contribution to the script: a way to shedule to turn off the plug (hardcoded to 30 minutes). If called another time, the last call cancel any previous schedule and reset the schedule to 30 min.
I trigger that command when a printer finish its job, in order to turn off that printer after a while, if no other print job is launched (in which case, the timeout is reset to 30 min on each print job).
cmd_schedule_switch_off(){
# Cancel any scheduled turn-off
# Browse all AT tasks and, for those containing the script name ($0), ask AT to stop them
for j in $(atq | cut -f 1);
do
if at -c $j | grep -q $0; then
echo Stop scheduled turn-off task $j
at -r $j
fi
done
# Schedule in 30 minutes to turn off the plug
echo "$0 $ip $port off" | at now+30minute
}
Hi Here is my small contribution to the script: a way to shedule to turn off the plug (hardcoded to 30 minutes). If called another time, the last call cancel any previous schedule and reset the schedule to 30 min.
I trigger that command when a printer finish its job, in order to turn off that printer after a while, if no other print job is launched (in which case, the timeout is reset to 30 min on each print job).