HI @bara.
I have posted a quick and easy solution using current RouterOS versions (>=7.17) for this task here
Mikrotik Scripting - Quickly filter Router-Log by datetime
Examples for your specific needs:
Your entries since "24 hours ago":
/log print where (([:timestamp]+([/system clock get gmt-offset]."s"))-[:totime (time)]) <= 24h && message ~ "connected" && topics ~ "ppp"
or all logs starting the current day at midnight
/log print where [:totime (time)] >= [:totime [/system clock get date]] && message ~ "connected" && topics ~ "ppp"
or between two specified dates
/log print where [:totime (time)] >= [:totime "2025-02-27 00:00:00"] && [:totime (time)] < [:totime "2025-02-28 00:00:00"] && message ~ "connected" && topics ~ "ppp"
Just choose the solution which fits your needs.
Regards @colinardo
Hi, thank you its working for me now i must learn your script its new for me. before i open this forum i try do this
:foreach Log in=filter do={
global formattedDate do={
:local date [/system clock get date]
:local month [:pick $date 5 7]
:local day [:pick $date 8 10]
:local year [:pick $date 0 4]
:return [($year . "-" . $month . "-" . ($day - 1))]
:set formattedDate [$formattedDate]
:put [$formattedDate]
}
:local Yesterday [$formattedDate]
/log print file=ppp_test_logs.txt where time~"Yesterday" && topics~"ppp" && message~"connected"
}
But not working