Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3289746
  • 博文数量: 515
  • 博客积分: 5116
  • 博客等级: 大校
  • 技术积分: 4137
  • 用 户 组: 普通用户
  • 注册时间: 2006-09-30 11:24
个人简介

黑马王子就是我! 技术认证:系统分析师,网络规划设计师,网络工程师,信息系统监理师,系统集成项目管理师,初级程序员,MCSE,MCDBA,CCNA 目前主攻虚拟化技术,VPN,系统架构,集群和高可用性等。

文章分类

全部博文(515)

文章存档

2023年(11)

2022年(17)

2021年(19)

2020年(28)

2019年(42)

2018年(53)

2017年(41)

2016年(33)

2015年(43)

2014年(25)

2013年(13)

2011年(6)

2010年(28)

2009年(47)

2008年(55)

2007年(26)

2006年(28)

分类: 系统运维

2015-06-08 15:46:51

摘要:相信大家都是用过Windows的人。对于Windows下饱受诟病的各种垃圾文件都需要自己想办法删除,不然你的系统将会变得越来越大,越来越迟钝!windows怎么清理垃圾相信大家都知道的,那么linux下怎么清理系统垃圾呢?

 Linux的文件系统比Windows的要优秀,不会产生碎片,对于长时间运行的服务器来说尤为重要,而且Linux系统本身也不会像Windows一样产生大量的垃圾文件。不知道这个说法有没有可信度!至少我们可以确定的是linux系统的文件系统是比较优秀的!

错误

rm -f logfile  

原因

应用已经打开文件句柄,直接删除会造成:

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

       2.显示磁盘空间未释放

正确

cat /dev/null > logfile

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

#!/bin/sh
cat /dev/null > /var/log/syslog
cat /dev/null > /var/adm/sylog
cat /dev/null > /var/log/wtmp
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/messages
cat /dev/null > /var/log/openwebmail.log
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/secure
cat /dev/null > /var/log/httpd/error_log
cat /dev/null > /var/log/httpd/ssl_error_log
cat /dev/null > /var/log/httpd/ssl_request_log
cat /dev/null > /var/log/httpd/ssl_access_log

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

sudo apt-get autoclean 清理旧版本的软件缓存
sudo apt-get clean 清理所有软件缓存
sudo apt-get autoremove 删除系统不再使用的孤立软件

阅读(3984) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~