HOW TO REDUCE OR DELETE A DAEMON.LOG THAT IS TOO LARGE

I recently encountered a server where the log files were taking up too much space.

The "daemon.log" was over 3 GB and the syslog is over 2 GB.

Those sizes are not normal !!!

If you are in a similar situation, you should look at the files (both) to see what is producing all that data.

Neither of the files should be that large; most likely there is some log message that keeps repeating due to a bug in the software that causes it to send a useless message too often, or something wrong in the configuration that causes errors too often. The ideal solution is to correct whatever is causing such a high number of logs.

Log rotation/deletion is handled by logrotate, which you should be able to configure to rotate your logs by size, which will work as a workaround to keep your disk from filling up. This is not a good long term solution, as important logs can be deleted very quickly. In Debian it is configured by files in /etc/logrotate.d/.

As an immediate stop-gap measure to make room again, only if you are sure that there is nothing important or useful to debug the problem in these logs. You can truncate the log files.

​​​​​​​ truncate -s 0 nombrefichero

And after the truncate restart the daemon and rsyslog. This permanently deletes all your logs, so don't do it regularly!

Tags

Have Any Project in Mind?

If you want to do something in Drupal maybe you can hire me.

Either for consulting, development or maintenance of Drupal websites.