下面是文件
-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
我怎样才能删除它?直接删除会影响吗?
提前致谢。
最佳答案
管理日志的最佳方式是使用 Logrotate
这是 Serhii's comment关于您的其他类似问题:
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 userotate
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).
您可以删除日志,但取决于您正在运行的软件 - 如果其中一些需要日志的某些部分或以任何方式使用它们 - 如果您删除它们,它将停止工作,因为有意的。
您还可以查看日志并对其进行分析,以了解哪个软件写入的数据最多,并尝试对其进行重新配置,以便生成的日志信息数量显着下降。那 - 结合 logrorate
应该会产生令人满意的结果。
如果这还不够,您可以将日志存储在 bucket 中 和 mount it as a disk在你的虚拟机文件系统中。这样,您的 VM 上安装的任何软件都可以写入。
但这会招致一些charges for using the bucket storage所以请记住这一点。
关于linux -/var/log/daemon.log 占用的空间多了怎么减少呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60560729/