wiyat
January 15, 2010, 6:06pm
1
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/t/cant-remove-userman-logs/18531/1
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
January 18, 2010, 10:30am
2
Dear
All
Can you help me with this please
hi
you can use
/tools/user-manager/logs/remove
and enter
:numbers:1-XXXXX
and enter
good luck
use this command in terminal
/tool user-manager database clear-log
yes
enter
Hi. Any idea how to do it in ROS7?
The commands don’t seem to exist now.
/user-manager/session/remove [find where active=no]
kvee
April 17, 2023, 5:43am
7
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 ( http://forum.mikrotik.com/t/i-did-it-script-to-compute-unix-time/68576/23 ).
: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.