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

Aqu*_*wer 8 log-files disk-space-utilization

目前我有 3.5GB 的顶部日志文件
/var/log/atop/

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

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

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

Aqu*_*wer 10

使用这个技巧,我编辑了
/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

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


小智 5

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

乌班图: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 {} \;)& )
Run Code Online (Sandbox Code Playgroud)


EEA*_*EAA 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.
Run Code Online (Sandbox Code Playgroud)

  • `ls: 无法访问 /etc/atop/: 没有这样的文件或目录` (2认同)