Clear logs on vyos

Hi,

Is there anyways to clear the logs on vyos? Same as the cisco router “clear logging”

Thanks
Terry

Hello @terry

This option is currently not available, you can submit a feature request in this link https://phabricator.vyos.net/

Thank you.

Hi A.srividya,

Thanks for the info

is there any other ways to Deleted the Logs? delete the files?

accel-ppp/ bootstrap.log faillog messages.2 ntpstats/ telegraf/ vmware-network.5.log vmware-vmsvc.log
alternatives.log btmp frr/ messages.3 openvpn/ user/ vmware-network.6.log vyatta/
alternatives.log.1 btmp.1 lastlog messages.4 private/ vmware-network.1.log vmware-network.7.log wtmp
apt/ conserver/ live/ messages.5 salt/ vmware-network.2.log vmware-network.8.log wtmp.1
atop/ dpkg.log messages mgetty/ squid/ vmware-network.3.log vmware-network.9.log
auth.log dpkg.log.1 messages.1 nginx/ squidguard/ vmware-network.4.log vmware-network.log

these files are located in /var/log path which can be deleted with the linux command

rm -rf /var/log/* or rm -rf /var/log/<file_name>

The files will be recreated if any relevant logs are generated.

Hi I tried the same but im getting permission denied.

Run with sudo:

$ sudo rm -rf /var/log/*

thank you. yes cleared.

hello,
thanks for sharing your query.
if you want to clear all logs, than you just need to run command is “delete log file ”.

I NOT recommend to use rm -rf /va/log/*
As it also deletes and all directories. Some daemon’s configs depending on these directories, so it is a big risk to get some services not working. And big chance to get brick.

For example one of them:

vyos@r6-roll:~$ sudo rm -rf /var/log/*

vyos@r6-roll:~$ sudo systemctl start nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
vyos@r6-roll:~$ sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2021-05-26 19:49:45 EEST; 15s ago
     Docs: man:nginx(8)
  Process: 1866 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

May 26 19:49:45 r6-roll systemd[1]: Starting A high performance web server and a reverse proxy server...
May 26 19:49:45 r6-roll nginx[1866]: nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (2: No such file or directory)
May 26 19:49:45 r6-roll nginx[1866]: 2021/05/26 19:49:45 [emerg] 1866#1866: open() "/var/log/nginx/access.log" failed (2: No such file or directory)
May 26 19:49:45 r6-roll nginx[1866]: nginx: configuration file /etc/nginx/nginx.conf test failed
May 26 19:49:45 r6-roll systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
May 26 19:49:45 r6-roll systemd[1]: nginx.service: Failed with result 'exit-code'.
May 26 19:49:45 r6-roll systemd[1]: Failed to start A high performance web server and a reverse proxy server.
vyos@r6-roll:~$
3 Likes