How to clear logs


#1

Hello,

I use logread -f to see the logs on target.
Is there a way to clean that log?
Can I dump the contetns of the log to file in an easy way?

thanks
BR
Luigi


#2

Hi @luigitondo,

unfortunately the busybox syslog doesn’t have a ‘clear’ function, so AFAIK, the only way to clear it is to restart the daemon, which has problematic impacts on sandboxed apps as syslog recreates a /dev/log, so if you want to get a system fully operational after a syslog restart … you would need to do a legato restart.

If you end up finding a better solution please let us know, as it is proving to be quite problematic for our tests.
I believe we could work on a patch for busybox syslog that would clear the logs when sent a signal.
I’m thinking about something like:

PID_SYSLOGD=$(ps x | grep syslog | grep -v grep | awk '{print $1}')
kill -HUP $PID_SYSLOGD

We could also imagine adding a -c, --clear arg to logread so as to clear the ring buffer just like dmesg.

So far though I’ve not had time to work on that though :frowning:

Thanks


#3

Hi,

thanks for your reply.
I do not have better solutions, unfortunately.
I think that the “-c/ --clear” option for logread would be great.

BR
Luigi