/var/log/daemon.log taking more space how to reduce it?

Viewed 4263

below are the files

-rw-r----- 1 root        adm  4.4G Mar  6 09:04 daemon.log
-rw-r----- 1 root        adm  6.2G Mar  1 06:26 daemon.log.1
-rw-r----- 1 root        adm   50M Feb 23 06:26 daemon.log.2.gz
-rw-r----- 1 root        adm   41M Feb 17 06:25 daemon.log.3.gz
-rw-r----- 1 root        adm   72K Feb  9 06:25 daemon.log.4.gz

how can I remove it? will it affect if I directly delete it?

Thanks in advance.

1 Answers

Best way to manage the logs would be to use Logrotate

This is Serhii's comment on your other similar question:

Have a look at this Logrotate tutorial linode.com/docs/uptime/logs/use-logrotate-to-manage-log-files. You can use size to force log rotation when it grows bigger than the specified [value], also you can use rotate to control how many times a log is rotated before old logs are removed (If you set it to 0 logs will be removed immediately after they are rotated).

You can delete the logs but depending on the software you're running - if some of it needs some part of logs or utilises them in any way - if you delete them it will stop working as intended.

You can also have a look at the logs and analyse them to see which software writes the most data and try to reconfigure it so the number of logs info generated will drop significantly. That - combined with logrorate should yield satisfactory results.

And if that's not enough you can store your logs in a bucket and mount it as a disk in your VM's filesystem. That way any software installed on your VM will be able to write to it.

But this will incur some charges for using the bucket storage so keep that in mind.

Related