Community discussions

MikroTik App
 
wiyat
newbie
Topic Author
Posts: 46
Joined: Tue Jan 12, 2010 9:38 pm
Contact:

How to remove logs under tools user-manager session

Fri Jan 15, 2010 8:06 pm

Dear
All


I have problem with my Radius because it have 2 Millions of logs but i don't know how I can remove/delete because the only way that i know if one by one, this process isn't good to me.- For this reason I request to you the help, maybe you know any script to execute and delete automatically this logs that I have under user-manager session at the same time I have more logs under /tools user-manager logs but I don't know if the same information.

My request is: Did you know any script that can remove this log, please

I read on internet on the next link the follow information: http://forum.mikrotik.com/viewtopic.php?f=10&t=21214


CLEAR USERMAN LOG SCRIPT:

:local Flag
:set Flag [/tool user-manager log find]
:if ([:len $Flag] > 0) do={/tool user-manager log print append file log;/tool user-manager log remove [/tool user-manager log find];}

BUT WHEN I EXECUTE THE BELOW SCRIPT, NOT WORK FINE I GET THE NEXT ERROR:
:set Flag [/tool user-manager log find]
syntax error (line 1 column 13)

I don't know if the problem is that when the other user made the below script used the other mikrotik OS version.

Thank you, please send me your comments.

Best regards.

mark
 
wiyat
newbie
Topic Author
Posts: 46
Joined: Tue Jan 12, 2010 9:38 pm
Contact:

Re: How to remove logs under tools user-manager session

Mon Jan 18, 2010 12:30 pm

Dear
All

Can you help me with this please
 
User avatar
romuotik
just joined
Posts: 10
Joined: Sat Jul 19, 2008 4:29 am
Location: Egpyt
Contact:

Re: How to remove logs under tools user-manager session

Tue Nov 05, 2013 5:07 pm

hi
you can use

/tools/user-manager/logs/remove
and enter
:numbers:1-XXXXX
and enter
good luck
 
User avatar
romuotik
just joined
Posts: 10
Joined: Sat Jul 19, 2008 4:29 am
Location: Egpyt
Contact:

Re: How to remove logs under tools user-manager session

Thu Sep 02, 2021 8:02 pm

use this command in terminal

/tool user-manager database clear-log
yes
enter
:)
 
sebaShannon
just joined
Posts: 4
Joined: Tue Sep 17, 2019 5:13 pm

Re: How to remove logs under tools user-manager session

Wed Oct 05, 2022 6:00 pm

Hi. Any idea how to do it in ROS7?

The commands don't seem to exist now.
 
User avatar
own3r1138
Long time Member
Long time Member
Posts: 680
Joined: Sun Feb 14, 2021 12:33 am
Location: Pleiades
Contact:

Re: How to remove logs under tools user-manager session

Thu Oct 06, 2022 6:51 am

/user-manager/session/remove [find where active=no]
 
User avatar
kvee
newbie
Posts: 38
Joined: Mon Feb 13, 2023 7:59 pm

Re: How to remove logs under tools user-manager session

Mon Apr 17, 2023 8:43 am

To clear all logs, use script by romuotik's comment.

To delete one that expired (by your limit), use this one.
The required permissions are: read,write,test
# Convert date/time to timestamp. Original source code by ( https://forum.mikrotik.com/viewtopic.php?p=994844#p994849 ).
:global datetime2epoch do={
    :local inputDateTime "$[/system clock get date] $[/system clock get time]"
    if ([:len $1]>0) do={
        :set inputDateTime $1
    }
    :local vdate [:pick $inputDateTime  0 [:find $inputDateTime  " " -1]]
    :local vtime [:pick $inputDateTime  ([:find $inputDateTime  " " -1] + 1) [:len $inputDateTime ]]
    :local vgmt  [/system clock get gmt-offset]; :if ($vgmt > 0x7FFFFFFF) do={:set vgmt ($vgmt - 0x100000000)}
    :if ($vgmt < 0) do={:set vgmt ($vgmt * -1)}
    :local arrm  [:toarray "0,0,31,59,90,120,151,181,212,243,273,304,334"]
    :local yyyy  [:pick $vdate 7 11] ; :if ((($yyyy - 1972) % 4) = 0) do={:set ($arrm->1) -1; :set ($arrm->2) 30}
    :local M     ([:find "xxanebarprayunulugepctovecANEBARPRAYUNULUGEPCTOVEC" [:pick $vdate 1 3] -1] / 2); :if ($M>12) do={:set M ($M - 12)}
    :local totd  ((($yyyy - 1970) * 365) + (($yyyy - 1972) / 4) + ($arrm->$M) + [:pick $vdate 4 6])
    :return      (((((($totd * 24) + [:pick $vtime 0 2]) * 60) + [:pick $vtime 3 5]) * 60) + [:pick $vtime 6 8] - $vgmt)
}
# end function ---------------------------------


:local username
:local logtime
:local logtimeTs
# number of seconds for hotspot user's log timeout
:local logTimeout 7200
# current log's timeout timestamp.
:local curLogTimeoutTs
# current timestamp.
:local currentTs

:foreach i in [/tool user-manager log find] do={
    :set username [/tool user-manager log get $i user-orig];
    :set logtime [/tool user-manager log get $i time];
    :set logtimeTs [$datetime2epoch [/tool user-manager log get $i time]];
    :set curLogTimeoutTs ($logtimeTs + $sessionTimeout)
    :set currentTs [$datetime2epoch]
    if ($curLogTimeoutTs <= $currentTs) do={
        #:put "$username has timedout at $logtime."; # for testing only.
        [/tool user-manager log remove numbers=$i]
    }
};
Use `/system scheduler` to schedule this script once a day.

Who is online

Users browsing this forum: No registered users and 68 guests