使用CentOS系统的时候,经常会遇到系统日志文件非常大的情况,如果直接删除,会导致日志错误,不再生成日志,这时,我们可以使用下面的方法清空日志。
CentOS 6系统
cat /dev/null > /var/log/boot.logcat /dev/null > /var/log/btmpcat /dev/null > /var/log/croncat /dev/null > /var/log/dmesgcat /dev/null > /var/log/dracut.logcat /dev/null > /var/log/lastlogcat /dev/null > /var/log/maillogcat /dev/null > /var/log/messagescat /dev/null > /var/log/securecat /dev/null > /var/log/spoolercat /dev/null > /var/log/tallylogcat /dev/null > /var/log/wtmpcat /dev/null > /var/log/yum.log
CentOS 7系统
cat /dev/null > /var/log/boot.logcat /dev/null > /var/log/btmpcat /dev/null > /var/log/croncat /dev/null > /var/log/dmesgcat /dev/null > /var/log/firewalldcat /dev/null > /var/log/grubbycat /dev/null > /var/log/lastlogcat /dev/null > /var/log/mail.infocat /dev/null > /var/log/maillogcat /dev/null > /var/log/messagescat /dev/null > /var/log/securecat /dev/null > /var/log/spoolercat /dev/null > /var/log/syslogcat /dev/null > /var/log/tallylogcat /dev/null > /var/log/wpa_supplicant.logcat /dev/null > /var/log/wtmpcat /dev/null > /var/log/yum.log