CentOS系统磁盘空间占满清空系统日志方法

CentOS系统磁盘空间占满清空系统日志方法

使用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.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
<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.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/<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
内容看完了
© 版权声明
1:本网站名称:蜡笔傻新
2:本站永久网址:https://labishaxin.com/
3:本站部分内容收集于互联网,如果有侵权内容、请联系我们删除,不妥之处,敬请谅解
4:本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责
5:本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
6:本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新
点赞0赞赏 分享
评论 抢沙发

请登录后发表评论