/var/log日志文件过大

1.messages文件

/etc/systemd/system.conf 中 LogLevel=info 设置成如下:
#LogLevel=info
LogLevel=notice
通过系统命令,修改日志配置文将件
systemd-analyze set-log-level notice
重启服务
systemctl restart rsyslog

 编辑/etc/crontab,首行增加或修改为

MAILTO=" "

重启计划任务

service crond reload
service crond restart

ps:可能需要新建目录

/var/spool/postfix/maildrop

 

2.maillog文件

  方式一: 关闭maillog日志,修改 /etc/rsyslog.conf

将
mail.*
改为
# mail.*

然后重启服务
systemctl restart rsyslog

 

方式二:修改日志保留时间

文件:/etc/logrotate.conf 

1)将 rotate 4 改为1

2)将 weekly 改为 daily

修改后重启服务
systemctl restart rsyslog

默认含义是:每周切割日志,保留4份
修改后的含义是:每日切割日志,保留1份

 

3.journal文件

方案1:只保留近一周日志
journalctl --vacuum-time=1w

方案2:保留指定大小日志
journalctl --vacuum-size=200M

 

posted @ 2022-10-25 10:03  null_v  阅读(1003)  评论(0)    收藏  举报