/Var/Log/Daemon.Log Taking More Space How to Reduce It

In GCP VM /var/log taking more space. How to reduce it?

can anyone tell me what are those below files?

No, because they depend of what software is installed. But some of them are very important, for example auth.log records authorization tries, daemon.log logs daemons activity, and so on. They serve for debugging, accounting and so on.

and what happen if I remove them?

Probably nothing dangerous, especially those like .1 .2 or .old.gz and so on. But logrotate would be the correct solution to try; depending on the distribution it can be easy to use (just install the package) or it may require quite hand-made configuration.

Docker daemon log taking up too much disk space

Just to close this off, this is no longer an issue in linuxkit. They have since added logging support using memlogd, and their own log writer, which handles automatic rotation. This is the link to their logging documentation.

The yaml is configured like so:

init:
# A circular buffer that captures logs from onboot and service-level containers
- linuxkit/memlogd:v0.7
...
services:
- name: write-and-rotate-logs
image: foobar/logwrite
command: ["/usr/bin/logwrite",
"-log-dir", "/persistent/log/bespin",
# Keep at most 25 files (Note: file numbers are 0-based)
"-max-log-files", "25",
# Max log file size set to 200MB (200 * 1024 * 1024 = 209,715,200 bytes)
"-max-log-size", "209715200"]

This will capture all linuxkit service logs, including docker daemon logs, and write them to disk. It handles rotation as it writes.

Docker container logs taking all my disk space

Docker 1.8 has been released with a log rotation option. Adding:

--log-opt max-size=50m 

when the container is launched does the trick. You can learn more at:
https://docs.docker.com/engine/admin/logging/overview/

Ubuntu: large syslog and kern.log files

Have you checked the content of those files? There's obviously something going on with your server causing events to be generated. Resolve whatever issue is causing that, and your logs should return to their normal size.

To temporary solve the issue, type

echo "" > /var/log/kern.log
echo "" > /var/log/syslog
service syslog restart
journalctl --vacuum-size=50M

You need to be root user for this: enter sudo su, your password, and then the above commands

Are log files safe to delete?

Actually you are in a better position to answer your own question. Most of these logs are systems/application logs. I suggest you do some research to try to understand what are these logs file before you delete them.

But to free up disk space, I suggest instead of deleting, you should truncate these log file.

> /var/log/user.log
> /var/log/apache2/error.log

You can read more on rm vs truncate pro and cons.



Related Topics



Leave a reply



Submit