Hello everyone
I’m looking for a script that I would run every day at midnight, to delete users exceeding 7 days since the first connection as well as the associated sessions.
I have 3 privileges:
1 week
3 days
3 hours
I would like to repeat the script for each profile
so I’m looking to make a comparison between the date or time of the first connection (1 week, 3 days, 3 hours) and delete the user concerned as well as their session
Thank you for your help
Greetings, I have had this script running for some time friend, paste it as it is in each of the “User Profiles” that you have.
:local comment "IN USE"
:local userprofile [ip hotspot user get [find where name="$user"] profile]
:if ([/ip hotspot user get $user comment]="") do={[/ip hotspot user set $user comment=$comment]}
[/system scheduler
add comment= [/ip hotspot user profile get [find where name="$userprofile"] name] name=$user on-event="/ip hotspot user remove \"$user\" \r\
\n/system scheduler remove [find where name=\"$user\"] \r\
\n\r\
" interval= [/ip hotspot user profile get [find where name="$userprofile"] session-timeout]]
I hope it is useful to you.
hello and thank you for the feedback
but I use useman, I don’t think the user is deleted at the same time on it
here is my configuration of my userman:
# mar/01/2024 08:20:30 by RouterOS 6.49.13
# software id =
#
#
#
/tool user-manager profile
add name=User-1-Semaine name-for-users="" override-shared-users=10 owner=admin price=0 starts-at=logon validity=0s
add name="user 60s" name-for-users="" override-shared-users=10 owner=admin price=0 starts-at=logon validity=0s
add name=User-3-jours name-for-users="" override-shared-users=10 owner=admin price=0 starts-at=logon validity=0s
add name=User-3-heures name-for-users="" override-shared-users=10 owner=admin price=0 starts-at=logon validity=0s
/tool user-manager profile limitation
add address-list="" download-limit=0B group-name="" ip-pool="" ip-pool6="" name=60s owner=admin transfer-limit=0B upload-limit=0B uptime-limit=1m
add address-list="" download-limit=0B group-name="" ip-pool="" ip-pool6="" name=Hotspot-3-jours owner=admin rate-limit-min-rx=10485760B rate-limit-min-tx=10485760B rate-limit-rx=10485760B \
rate-limit-tx=10485760B transfer-limit=0B upload-limit=0B uptime-limit=3d
add address-list="" download-limit=0B group-name="" ip-pool="" ip-pool6="" name=Hotspot-3-heures owner=admin rate-limit-min-rx=10485760B rate-limit-min-tx=10485760B rate-limit-rx=10485760B \
rate-limit-tx=10485760B transfer-limit=0B upload-limit=0B uptime-limit=3h
add address-list="" download-limit=0B group-name="" ip-pool="" ip-pool6="" name=Hotspot-1-semaine owner=admin rate-limit-min-rx=10485760B rate-limit-min-tx=10485760B rate-limit-rx=10485760B \
rate-limit-tx=10485760B transfer-limit=0B upload-limit=0B uptime-limit=1w
/tool user-manager database
set db-path=user-manager
/tool user-manager profile profile-limitation
add from-time=0s limitation=60s profile="user 60s" till-time=23h59m59s weekdays=sunday,monday,tuesday,wednesday,thursday,friday,saturday
add from-time=0s limitation=Hotspot-3-heures profile=User-3-heures till-time=23h59m59s weekdays=sunday,monday,tuesday,wednesday,thursday,friday,saturday
add from-time=0s limitation=Hotspot-1-semaine profile=User-1-Semaine till-time=23h59m59s weekdays=sunday,monday,tuesday,wednesday,thursday,friday,saturday
add from-time=0s limitation=Hotspot-3-jours profile=User-3-jours till-time=23h59m59s weekdays=sunday,monday,tuesday,wednesday,thursday,friday,saturday
OK, I made progress on my code.
now I have a problem adding dates:
my viriable: $lastSeenStr which has the format for example: mar/04/2024 15:53:20 and my other variable: $validity which has the value for example: 3d00:00:00
I can’t add the dates
do you have an idea ?
THANKS