环境说明
CentOS Linux release 8.3.2011
问题说明
磁盘占用90%,利用df -hl & du -sh命令找到
/var/log/messages
/var/log/journal
占用过多,分析日志查看原因
大量:
Jun 20 03:40:31 iZbp14vt99zpj8dde2fdlmZ crond[208986]: No configuration file found at /root/.esmtprc or /etc/esmtprc
解决步骤
查看当前日志占用磁盘的空间的总大小
journalctl --disk-usage
[root@iZbp14vt99zpj8dde2fdlmZ journal]# journalctl --disk-usage Archived and active journals take up 3.9G in the file system.
指定日志文件保存多久
保存最近一周:journalctl --vacuum-time=1w
保存最近一年:journalctl --vacuum-time=1years
[root@iZbp14vt99zpj8dde2fdlmZ journal]# journalctl --vacuum-time=1w Vacuuming done, freed 0B of archived journals from /var/log/journal/20210318142909815972522070876808.
指定日志文件最大空间
只保留500MB的日志:journalctl --vacuum-size=500M
只保留1GB的日志:journalctl --vacuum-size=1G
[root@iZbp14vt99zpj8dde2fdlmZ journal]# journalctl --vacuum-size=500M Vacuuming done, freed 3.5G of archived journals from /var/log/journal/20210318142909815972522070876808.
/var/log/messages
问题:No configuration file found at /root/.esmtprc or /etc/esmtprc
参考:
No configuration file found at /root/.esmtprc or /etc/esmtprc
Centos 7:yum install -y postfix
Centos 8:dnf install -y postfix