【转】Linux下如何清除系统日志

使用过Windows的人都知道,在使用windows系统的过程当中系统会变得愈来愈慢。而对于Windows下饱受诟病的各类垃圾文件都须要本身想办法删除,否则系统将会变得愈来愈大,愈来愈迟钝!windows怎么清理垃圾相信你们都知道的,那么linux下怎么清理系统垃圾呢?linux

Linux的文件系统比Windows的要优秀,不会产生碎片,对于长时间运行的服务器来讲尤其重要,并且Linux系统自己也不会像Windows同样产生大量的垃圾文件。不知道这个说法有没有可信度!至少咱们能够肯定的是linux系统的文件系统是比较优秀的!web

错误windows

  1. rm -f logfile 

缘由缓存

应用已经打开文件句柄,直接删除会形成:服务器

1.应用没法正确释放日志文件和写入spa

2.显示磁盘空间未释放日志

正确xml

  1. cat /dev/null > logfile 

把一下代码保存为.sh后缀脚原本运行便可清除Linux系统日志ssl

  1. #!/bin/sh  
  2.  
  3. cat /dev/null > /var/log/syslog  
  4.  
  5. cat /dev/null > /var/adm/sylog  
  6.  
  7. cat /dev/null > /var/log/wtmp  
  8.  
  9. cat /dev/null > /var/log/maillog  
  10.  
  11. cat /dev/null > /var/log/messages  
  12.  
  13. cat /dev/null > /var/log/openwebmail.log  
  14.  
  15. cat /dev/null > /var/log/maillog  
  16.  
  17. cat /dev/null > /var/log/secure  
  18.  
  19. cat /dev/null > /var/log/httpd/error_log  
  20.  
  21. cat /dev/null > /var/log/httpd/ssl_error_log  
  22.  
  23. cat /dev/null > /var/log/httpd/ssl_request_log  
  24.  
  25. cat /dev/null > /var/log/httpd/ssl_access_log 

另外清理linux系统垃圾还有如下命令rem

sudo apt-get autoclean 清理旧版本的软件缓存

sudo apt-get clean 清理全部软件缓存

sudo apt-get autoremove 删除系统再也不使用的孤立软件

相关文章
相关标签/搜索