如何让“atop”创建更少的日志文件?

如何让“atop”创建更少的日志文件?

目前我有大约 3.5GB 的 atop 日志文件
/var/log/atop/

我不需要那么多日志数据。
那里的文件最早是 28 天前的。

atop我找不到配置日志限制/配额/期限的方法。

如何降低磁盘空间使用率?

答案1

使用这个提示,我编辑了
/etc/init.d/atop

由于手册页上写着“四周”,所以显然有这个命令:
find $LOGPATH -name 'atop_*' -mtime +28 -exec rm {} \;

因此,28 天前的文件将被保留......

我把它改成了
find $LOGPATH -name 'atop_*' -mtime +1 -exec rm {} \;

并运行此命令:
sudo service atop _cron

现在最多只有昨天的日志,这就是我所需要的。

答案2

为我的版本添加答案(也可以在手册页中找到):

Ubuntu:17.04

$顶部-V

版本:2.2.6

该脚本位于: /usr/share/atop/atop.daily

我已将我的日志减少到 7 天。

38c38
< ( (sleep 3; find $LOGPATH -name 'atop_*' -mtime +28 -exec rm {} \;)& )
---
> ( (sleep 3; find $LOGPATH -name 'atop_*' -mtime +7 -exec rm {} \;)& )

答案3

一定要阅读man页面。一定要阅读。

通过运行 man atop

如果你这么做了,你会看到这样的情况:

When  atop is installed, the script atop.daily is stored in the /etc/atop directory.
This scripts takes care that atop is activated every day at midnight to
write compressed binary data to  the  file /var/log/atop/atop_YYYYMMDD
with  an interval of 10 minutes. Furthermore the script removes all raw
files which are older than four weeks. The script is activated via the cron
daemon using the file /etc/cron.d/atop with the contents

    0 0 * * * root /etc/atop/atop.daily

When the RPM `psacct` is installed, the process accounting is automatically
restarted via the logrotate mechanism. The file
/etc/logrotate.d/psaccs_atop takes care that atop is finished just before
the rotation of the process accounting file and  the  file
/etc/logrotate.d/psaccu_atop takes care that atop is restarted again after
the rotation.  When the RPM `psacct' is not installed, these logrotate-files
have no effect.

答案4

所有给出的答案在某些时候都是正确的,尽管atop似乎多次更改了配置文件的位置。正如@EEAA 所建议的,请检查man atop特定版本的配置位置。

对于我来说,在 v2.7.1 上,配置位于下方/etc/default/atop并提供所有必要的信息。

相关内容