简体   繁体   English

/var/log/daemon.log 占用更多空间如何减少它?

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

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.提前致谢。

Best way to manage the logs would be to use Logrotate管理日志的最佳方法是使用 Logrotate

This is Serhii's comment on your other similar question:这是Serhii对您的其他类似问题的评论

Have a look at this Logrotate tutorial linode.com/docs/uptime/logs/use-logrotate-to-manage-log-files.看看这个 Logrotate 教程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 ).您可以使用size来强制日志轮换当它变得大于指定的[value] ,您也可以使用rotate来控制在删除旧日志之前日志轮换的次数(如果将其设置为 0 日志将被立即删除旋转后)。

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.那 - 结合logrorate应该会产生令人满意的结果。

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.如果这还不够,您可以将日志存储在存储桶中,并将其作为磁盘安装在 VM 的文件系统中。 That way any software installed on your VM will be able to write to it.这样,您的 VM 上安装的任何软件都可以写入其中。

But this will incur some charges for using the bucket storage so keep that in mind.但这会因使用存储桶存储而产生一些费用,因此请记住这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM