I’m sure this is an easy one, but I’m looking for a script to run every hour to locate any devices in the Hosts that are idle for more than 8 hours and remove them. We can’t just use idle-timeout since there are other devices in the host list like IP Bindings. Any ideas or anyone using a script now?
Thanks.
This should do it, syntax might need to be edited a bit.
:foreach ENTRY in=[/ip hotspot host find] do={
:local idleTime [/ip hotspot host get number=$ENTRY idle-time];
:if ($idleTime > 8h ) do={
/ip hotspot host remove number=$ENTRY
}
}
Works perfectly. Thanks.
In case you need to remove hosts that are not authorized and bypassed (for example connected hotspot users and antennas or network bypassed devices), then, you may use this script:
:foreach ENTRY in=[/ip hotspot host find where !bypassed && !authorized] do={
:local idleTime [/ip hotspot host get number=$ENTRY idle-time];
:if ($idleTime > 2h ) do={
/ip hotspot host remove number=$ENTRY
}
}
Just for your help…