Page 1 of 1

User manager delete expired users

Posted: Tue Sep 16, 2014 10:24 am
by letabawireless
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.

Re: User manager delete expired users

Posted: Tue Sep 23, 2014 8:11 pm
by Abdock

Re: User manager delete expired users

Posted: Wed Oct 01, 2014 5:36 am
by parinya1957
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.

Re: User manager delete expired users

Posted: Wed Oct 01, 2014 11:52 am
by letabawireless
Kudos! That worked great !!

Re: User manager delete expired users

Posted: Sat Feb 11, 2017 6:03 pm
by enjoy
not running on 6.38.1, why ?

Re: User manager delete expired users

Posted: Wed Feb 22, 2017 3:44 pm
by Wolfgang
@ enjoy: Do you run it as scheduled task? What are the rights you set on the script and the task?

Re: User manager delete expired users

Posted: Sun Apr 30, 2017 12:24 am
by ahmedalmi
this work in 6.38

/tool user-man user remove [find !actual-profile];

Re: User manager delete expired users

Posted: Thu Oct 19, 2017 7:02 pm
by Hamosal
/tool user-manager user remove [find where !actual-profile and uptime-used>0s];

Re: User manager delete expired users

Posted: Fri Jan 26, 2018 2:31 am
by fernando1787
/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.

Re: User manager delete expired users

Posted: Thu May 03, 2018 12:36 am
by hardwarematik
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

Re: User manager delete expired users

Posted: Thu May 03, 2018 5:18 pm
by hardwarematik
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

Re: User manager delete expired users

Posted: Fri Jul 06, 2018 3:54 pm
by tawasol4sy
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/