Linux 查看空间使用情况的实例详解

2019-01-16 23:06:03王旭

第六步:进入tomcat的程序目录,查看哪个目录占用的空间最大。如下,发现是一个【fare】的目录占用了46G,而【logs】是日志目录却占用了23M。

[root@hostname ~]# cd apache-tomcat-6.0.36-linux [root@hostname apache-tomcat-6.0.36-linux]# ls backup bin conf fare lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work [root@hostname apache-tomcat-6.0.36-linux]# du -sh * 92K backup 882M bin 108K conf 46G fare 6.8M lib 40K LICENSE 23M logs 4.0K NOTICE 12K RELEASE-NOTES 16K RUNNING.txt 7.9M temp 188M webapps 7.1M work

第七步:继续一探究竟【fare】目录里面到底存放的是什么类型的目录或者文件。如下看到有很多类似日志文件,如common.log和pricing.log。通过和开发人员沟通之后,确定确实日志文件。

[root@hostname apache-tomcat-6.0.36-linux]# cd fare [root@hostname fare]# ls common.log common.log.2017-09-21 common.log.2017-10-03 pricing.log.2017-09-10 pricing.log.2017-09-22 pricing.log.2017-10-04 common.log.2017-09-10 common.log.2017-09-22 common.log.2017-10-04 pricing.log.2017-09-11 pricing.log.2017-09-23 pricing.log.2017-10-05 common.log.2017-09-11 common.log.2017-09-23 common.log.2017-10-05 pricing.log.2017-09-12 pricing.log.2017-09-24 pricing.log.2017-10-06 common.log.2017-09-12 common.log.2017-09-24 common.log.2017-10-06 pricing.log.2017-09-13 pricing.log.2017-09-25 pricing.log.2017-10-07 common.log.2017-09-13 common.log.2017-09-25 common.log.2017-10-07 pricing.log.2017-09-14 pricing.log.2017-09-26 pricing.log.2017-10-08 common.log.2017-09-14 common.log.2017-09-26 common.log.2017-10-08 pricing.log.2017-09-15 pricing.log.2017-09-27 pricing.log.2017-10-09 common.log.2017-09-15 common.log.2017-09-27 common.log.2017-10-09 pricing.log.2017-09-16 pricing.log.2017-09-28 spring.log common.log.2017-09-16 common.log.2017-09-28 common.zip pricing.log.2017-09-17 pricing.log.2017-09-29 struts2.log common.log.2017-09-17 common.log.2017-09-29 framework.log pricing.log.2017-09-18 pricing.log.2017-09-30 xwork2.log common.log.2017-09-18 common.log.2017-09-30 hibernate.log pricing.log.2017-09-19 pricing.log.2017-10-01 common.log.2017-09-19 common.log.2017-10-01 hibernate.log.2017-01-03 pricing.log.2017-09-20 pricing.log.2017-10-02 common.log.2017-09-20 common.log.2017-10-02 pricing.log pricing.log.2017-09-21 pricing.log.2017-10-03

第八步:继续查看哪个目录或者文件占用的空间最大,发现都是common.log和pricing.log相关的文件占用的空间最大,都是700M以上。至此,已经查明占用根目录”/”空间最多的原因是tomcat的日志文件太多,而且每一个日志文件都很大。

[root@hostname fare]# du -sh *|sort -h 0 framework.log 0 hibernate.log.2017-01-03 0 spring.log 0 struts2.log 0 xwork2.log 4.0K hibernate.log 17M common.zip 215M pricing.log 216M common.log 667M pricing.log.2017-10-08 668M common.log.2017-10-08 674M common.log.2017-10-05 674M pricing.log.2017-10-05 678M common.log.2017-10-07 678M pricing.log.2017-10-07 679M common.log.2017-10-06 679M pricing.log.2017-10-06 683M common.log.2017-10-04 683M pricing.log.2017-10-04 690M pricing.log.2017-09-10 691M common.log.2017-09-10 711M common.log.2017-09-12 711M pricing.log.2017-09-12 719M pricing.log.2017-09-11 720M common.log.2017-09-11 737M common.log.2017-09-30 737M pricing.log.2017-09-28 737M pricing.log.2017-09-30 738M common.log.2017-09-28 742M common.log.2017-09-29 742M pricing.log.2017-09-29 744M pricing.log.2017-10-09 745M common.log.2017-10-09 751M common.log.2017-10-01 751M pricing.log.2017-10-01 754M common.log.2017-09-13 754M pricing.log.2017-09-13 760M common.log.2017-10-03 760M pricing.log.2017-10-03 783M pricing.log.2017-10-02 784M common.log.2017-10-02 791M pricing.log.2017-09-18 792M common.log.2017-09-18 797M common.log.2017-09-27 797M pricing.log.2017-09-27 804M common.log.2017-09-17 804M common.log.2017-09-19 804M pricing.log.2017-09-17 804M pricing.log.2017-09-19 808M common.log.2017-09-26 808M pricing.log.2017-09-26 815M pricing.log.2017-09-24 816M common.log.2017-09-24 821M common.log.2017-09-14 821M pricing.log.2017-09-14 821M pricing.log.2017-09-23 822M common.log.2017-09-23 826M common.log.2017-09-25 826M pricing.log.2017-09-25 827M common.log.2017-09-16 827M pricing.log.2017-09-15 827M pricing.log.2017-09-16 828M common.log.2017-09-15 831M common.log.2017-09-22 831M pricing.log.2017-09-22 851M common.log.2017-09-21 851M pricing.log.2017-09-21 860M common.log.2017-09-20 860M pricing.log.2017-09-20