/var/log/daemon.log占用更多空间如何减少呢? [英] /var/log/daemon.log taking more space how to reduce it?

查看:198
本文介绍了/var/log/daemon.log占用更多空间如何减少呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是文件

-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?

谢谢.

推荐答案

管理日志的最佳方法是使用Logrotate

Best way to manage the logs would be to use Logrotate

这是 Serhii的对您的其他类似问题发表评论:

请参阅此Logrotate教程linode.com/docs/uptime/logs/use-logrotate-to-manage-log-files.你可以使用 size 强制日志旋转,直到它变得大于指定的 [value] ,也可以使用 rotate 来控制多少删除旧日志之前旋转日志的次数(如果将其设置为轮换后,将立即删除0个日志).

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.

您还可以查看日志,并对其进行分析,以了解哪个软件写入的数据最多,然后尝试对其进行重新配置,这样生成的日志信息数量将大大减少.结合 logrorate 可以产生令人满意的结果.

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.

如果这还不够,您可以将日志存储在 ,然后将其装入磁盘到您的VM的文件系统.这样,VM上安装的所有软件都可以对其进行写入.

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.

这篇关于/var/log/daemon.log占用更多空间如何减少呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆