
使用CentOS系统的时候,经常会遇到系统日志文件非常大导致磁盘空间占满的情况,如果直接删除,会导致日志错误,不再生成日志,这时,我们可以使用下面的方法清空日志。
查看硬盘占用
<span class="hljs-attribute">df</span> -h<span class="hljs-attribute">df</span> -h
df -h
CentOS 6系统
<a target="_blank" href="https://labishaxin.com/tag/790.html" title="View all posts in cat">cat</a> /<a target="_blank" href="https://labishaxin.com/tag/791.html" title="View all posts in dev">dev</a>/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/<a target="_blank" href="https://labishaxin.com/tag/789.html" title="View all posts in log">log</a>/boot.logcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/btmpcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/croncat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/dmesgcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/dracut.logcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/lastlogcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/maillogcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/messagescat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/securecat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/spoolercat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/tallylogcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/wtmpcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/yum.log<a target="_blank" href="https://labishaxin.com/tag/790.html" title="View all posts in cat">cat</a> /<a target="_blank" href="https://labishaxin.com/tag/791.html" title="View all posts in dev">dev</a>/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/<a target="_blank" href="https://labishaxin.com/tag/789.html" title="View all posts in log">log</a>/boot.log
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/btmp
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/cron
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/dmesg
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/dracut.log
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/lastlog
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/maillog
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/messages
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/secure
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/spooler
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/tallylog
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/wtmp
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/yum.log
cat /dev/null > /var/log/boot.log
cat /dev/null > /var/log/btmp
cat /dev/null > /var/log/cron
cat /dev/null > /var/log/dmesg
cat /dev/null > /var/log/dracut.log
cat /dev/null > /var/log/lastlog
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/messages
cat /dev/null > /var/log/secure
cat /dev/null > /var/log/spooler
cat /dev/null > /var/log/tallylog
cat /dev/null > /var/log/wtmp
cat /dev/null > /var/log/yum.log
CentOS 7系统
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/boot.logcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/btmpcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/croncat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/dmesgcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/firewalldcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/grubbycat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/lastlogcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/mail.infocat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/maillogcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/messagescat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/securecat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/spoolercat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/syslogcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/tallylogcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/wpa_supplicant.logcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/wtmpcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/yum.logcat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/boot.log
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/btmp
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/cron
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/dmesg
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/firewalld
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/grubby
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/lastlog
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/mail.info
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/maillog
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/messages
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/secure
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/spooler
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/syslog
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/tallylog
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/wpa_supplicant.log
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/wtmp
cat /dev/<span class="hljs-literal">null</span> > /<span class="hljs-keyword">var</span>/log/yum.log
cat /dev/null > /var/log/boot.log
cat /dev/null > /var/log/btmp
cat /dev/null > /var/log/cron
cat /dev/null > /var/log/dmesg
cat /dev/null > /var/log/firewalld
cat /dev/null > /var/log/grubby
cat /dev/null > /var/log/lastlog
cat /dev/null > /var/log/mail.info
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/messages
cat /dev/null > /var/log/secure
cat /dev/null > /var/log/spooler
cat /dev/null > /var/log/syslog
cat /dev/null > /var/log/tallylog
cat /dev/null > /var/log/wpa_supplicant.log
cat /dev/null > /var/log/wtmp
cat /dev/null > /var/log/yum.log
内容看完了
© 版权声明
请登录后发表评论
注册