Community discussions

MikroTik App
 
letabawireless
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Thu Jul 26, 2012 5:11 pm

User manager delete expired users

Tue Sep 16, 2014 10:24 am

Hi
I have setup the following test Hotspot:
profile with validity of 5m
transfer limit 50m

So, the problem is that, old users pile up. In the real client setup, I have 100's of users, and what I have picked up is that when the start-time parameter gets to the status 'unknown', then it means that the account is expired. I would like to delete these users everyday, by use of a script. However, all of the web interface paramaters does not seem to be available on command line, which is not something Mikrotik normally does. Maybe I am doing something wrong ?

Please help, it is quite a mission to delete the users manually, and unprofessional to expect the client to do this.

Thanks for the help.
 
Abdock
Member Candidate
Member Candidate
Posts: 259
Joined: Sun Sep 25, 2005 10:50 pm

Re: User manager delete expired users

Tue Sep 23, 2014 8:11 pm

 
parinya1957
just joined
Posts: 24
Joined: Mon Mar 11, 2013 6:34 am
Location: Thailand

Re: User manager delete expired users

Wed Oct 01, 2014 5:36 am

Hi letabawireless,

To delete expired user in userman I used below script. You can schedule it to run on period you want but for me I run it once a week because I not have much user. I set user profile for limitation 1day (1d) and 1 month (4w2d) and I saw in user list that when user expired the actual-profile data will empty.

It works on ROS v6.19 for me both RB2011 and R951 but not work on ROS v6.15 (in previous my RB2011 is v6.15 and it not work).
# Automatic remove blank actual-profile user in User Manager for ROS v6.19
:local username

:foreach i in [/tool user-manager user find where !actual-profile] do={
  :set username [/tool user-manager user get $i name]
  :log error ("Remove user name $username")
  [/tool user-manager user remove $i]
}
Hope this will help.
 
letabawireless
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 63
Joined: Thu Jul 26, 2012 5:11 pm

Re: User manager delete expired users

Wed Oct 01, 2014 11:52 am

Kudos! That worked great !!
 
enjoy
Frequent Visitor
Frequent Visitor
Posts: 67
Joined: Fri Jul 18, 2008 8:29 pm

Re: User manager delete expired users

Sat Feb 11, 2017 6:03 pm

not running on 6.38.1, why ?
 
Wolfgang
just joined
Posts: 15
Joined: Thu Jan 28, 2016 12:33 pm

Re: User manager delete expired users

Wed Feb 22, 2017 3:44 pm

@ enjoy: Do you run it as scheduled task? What are the rights you set on the script and the task?
 
User avatar
ahmedalmi
Frequent Visitor
Frequent Visitor
Posts: 77
Joined: Sat Sep 13, 2014 5:52 pm
Location: sana'a yemen
Contact:

Re: User manager delete expired users

Sun Apr 30, 2017 12:24 am

this work in 6.38

/tool user-man user remove [find !actual-profile];
 
Hamosal
just joined
Posts: 1
Joined: Thu Oct 19, 2017 6:57 pm

Re: User manager delete expired users

Thu Oct 19, 2017 7:02 pm

/tool user-manager user remove [find where !actual-profile and uptime-used>0s];
 
fernando1787
just joined
Posts: 9
Joined: Mon Apr 11, 2016 6:32 pm

Re: User manager delete expired users

Fri Jan 26, 2018 2:31 am

/tool user-manager user remove [find where !actual-profile and uptime-used>0s];
Hello, I am having same problem, in some circumstances user expires but actual-profile is kept, i.e.: profile validity=1h , uptime-limit=1h, user log in, then close session before uptime-limit, then doesn't start sessions anymore. Profile expire by validity time, but user kept actual-profile value.

I am having problems to find a condition to remove users in this conditions.
 
hardwarematik
just joined
Posts: 3
Joined: Thu May 03, 2018 12:26 am

Re: User manager delete expired users

Thu May 03, 2018 12:36 am

Hi:
I know how to delete users using API in C# with the tik4net unit, it is great unit: IEnumerable<string> command = new string[] { "/tool/user-manager/user/remove", "=numbers=*" + textBox3.Text }, in the textBox3 you can enter the number of the item you want to delete. I'm interesting in to know how delete all the expired users using API with this unit, what should I wirte in my string?

IEnumerable<string> command = new string[] { "/tool/user-manager/user/remove", "[find where !actual-profile and uptime-used>0s]" }

Maybe work?? Because I really dont know how to use "find" command. Thanks in advance
 
hardwarematik
just joined
Posts: 3
Joined: Thu May 03, 2018 12:26 am

Re: User manager delete expired users

Thu May 03, 2018 5:18 pm

this work in 6.38

/tool user-man user remove [find !actual-profile];
Hi:
I know how to delete users using API in C# with the tik4net unit, it is great unit: IEnumerable<string> command = new string[] { "/tool/user-manager/user/remove", "=numbers=*" + textBox3.Text }, in the textBox3 you can enter the number of the item you want to delete. I'm interesting in to know how delete all the expired users using API with this unit, what should I wirte in my string?

IEnumerable<string> command = new string[] { "/tool/user-manager/user/remove", "[find where !actual-profile and uptime-used>0s]" }

Maybe work?? Because I really dont know how to use "find" command. Thanks in advance
 
tawasol4sy
just joined
Posts: 2
Joined: Thu Jul 05, 2018 6:30 am
Contact:

Re: User manager delete expired users

Fri Jul 06, 2018 3:54 pm

Scripts scan cards expired and the validity of their own sessions:

/ Tool user-manager user print brief without-paging;
: Foreach i in = [/ tool user-manager user find where! Actual-profile] do = {
: Local tawasol4sy [/ tool user-manager user remove $ i];
}

https://tawasol4sy.org/%D8%AD%D8%B0%D9% ... -mikrotik/

Who is online

Users browsing this forum: No registered users and 8 guests