OpenWrt Forum Archive

Topic: [solved]How to clear log messages ?

The content of this topic has been archived on 27 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

logread can get log info ,but i want to clear the logfile in my openwrt.
In linux, the command was used to clear log info in  /var/log/messages
echo "" > cat  /var/log/messages

1.Where do all log files locate in openwrt?
2.How to clear them?

(Last edited by elearn2014 on 9 Jun 2016, 07:48)

How about under /tmp ?

logread
Thu Jun  9 01:03:05 2016 authpriv.notice dropbear[1452]: Password auth succeeded for 'root' from 192.168.1.197:56760
Thu Jun  9 01:03:05 2016 authpriv.info dropbear[1452]: Exit (root): Exited normally
Thu Jun  9 01:03:10 2016 authpriv.info dropbear[1455]: Child connection from 192.168.1.197:43348
Thu Jun  9 01:03:12 2016 authpriv.notice dropbear[1455]: Password auth succeeded for 'root' from 192.168.1.197:43348
Thu Jun  9 01:03:12 2016 authpriv.info dropbear[1455]: Exit (root): Exited normally


ls /tmp
TZ                lib               resolv.conf       state
dhcp.leases       lock              resolv.conf.auto  sysinfo
dnsmasq.d         log               resolv.conf.ppp   usr
etc               opkg-lists        run
hosts             overlay           shm
ls /tmp/log
lastlog  wtmp

cat  /tmp/log/wtmp
cat  /tmp/log/lastlog

Why nothing output for the commands  `cat  /tmp/log/wtmp` and ` cat  /tmp/log/lastlog`?

Because the contents of the System log are not in a file but in  memory buffer internal to the log daemon. Logread accesses that buffer and outputs the contents  in cleartext.

if you want to clear the log, just restart the log daemon.

If i shutdown my router ,power off, then the log vasnish,it will not be saved??

Correct.

Is that the only way to clear the logs is to power it off??

Why isn't there a GUI "clear" function which would be logical?

(Last edited by videobruce on 26 Dec 2017, 17:41)

simply restart the log daemon and it will clear.

Is this under System/Startup: Initscripts using the "log" "Restart" entry??

indeed it is

Ok, how about the "Kernel" log, that wasn't cleared?

Too bad that function isn't available on the 'log' page. sad

the kernel log can be cleared with

dmesg -c

Where within LuCi can you enter command prompts, if there is one, I don't see it?

The only way to do it in luci is to use the custom commands module

opkg update
opkg install luci-app-commands

and then add it as a command under system custom commands.

Otherwise enter the command from a root shell prompt (ssh or telnet)

The discussion might have continued from here.