Email last 24hrs logs

Dear experts,

I’m looking for a ‘novice proof’ solution to send the logs from last 24hrs by email.

Found a solution to send full log, using Scheduler:

/log print  file=logs
delay 10
/tool e-mail send to="user@name.--" subject="$[/system identity get name]  logs" \
body="$[/system clock get date] log file" file=logs
delay 10
/file remove logs

However would like to limit log to only last 24hrs. How to achieve this?

Nobody any idea’s?

It’s possible to do some filtering, e.g. this at first sight works as expected:

/log print where topics~"account"

Another field offered by tab-completition is “time”, so I guess it’s possible to use that. But how exactly, I can’t tell. Having encountered RouterOS scripting before, I expect it to be something unintuitive and cumbersome.

after send the log, empty the logs…

without see your actual log configuration, this probably simply do what you want…

change first line of the script with…

/log print file=logs where buffer=memory
/system logging action
set [find where target=memory] memory-lines=1
:delay 1s
set [find where target=memory] memory-lines=1000

<<<insert the remaining script here>>>

schedule it at 23:59 and you have the last day logs only

The below script used to work in v6:
/log print where time>( [system clock get time] - 1h )
So you can schedule to run the script at the end of the day like below just don’t get negative in the subtraction.
/log print where time>( [system clock get time] - 23h50m )

But it doesn’t work in v7 anymore.

You can send all logs using syslog. See link in my signature for how to use Splunk to analyze them and graph them.

Seems to be the easiest solution, indeed. Although erasing the full log is not he most ideal scenario.

Surprised MT makes it so difficult, by using the current time/date notation.

Anyway, thanks all!