系统空间占用排查 tomcat超大日志catalina.out 删除 与df 状态更新
二、catalina.out占用多达60+G
并且其他诸如catalina.2016-03-29.log等具体日期的日志文件,个别的也有10G左右,直接删除这些大个头。df看稍有改善。针对catalina.out文件,它还在不停增长,可以
# echo > catalina.out /*来清空内容*/
度娘说可以用cronlog这么个东西来分割日志,官网都打不开了。算了,我直接粗暴的删除了这个文件catalina.out。在manager控制台重启tomcat之后,catalina.out不自动生成(bin/catalina.sh负责自动生成它)。 关键是df还是显示只有那么点空间可用。
# ps -ef | grep 12792 /*一看是java,也就是java/tomcat一致在占用这个删除的catalina.out 造成它实际并未释放*/
# bin/shutdown.sh /*关掉tomcat*/
# ps -ef | grep java /*确认java进程消失*/
# bin/startup.sh /*开启tomcat,java进程随之出现*/
# ls -ld /proc/*/fd/* 2>&1 | fgrep '(deleted)' /*现在那个catalina.out已经没有了*/
# df -h /*空间使用情况统计恢复正常*/
实例示例:
[root@df-prod deploy_wars]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 34G 3.8G 90% / devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 460K 3.9G 1% /run
[root@df-prod deploy_wars]# ps aux|grep java root 13294 0.0 0.0 112644 964 pts/0 S+ 15:18 0:00 grep --color=auto java deploy 31765 10.5 23.3 4857180 1872500 ? Sl Dec05 779:17 /usr/bin/java -Djava.util.logging.config.file=/home/deploy/tomcat/apache-tomcat-7.0.75-df/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.security.egd=file:/dev/./urandom -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/home/deploy/tomcat/apache-tomcat-7.0.75-df/endorsed -classpath /home/deploy/tomcat/apache-tomcat-7.0.75-df/bin/bootstrap.jar:/home/deploy/tomcat/apache-tomcat-7.0.75-df/bin/tomcat-juli.jar -Dcatalina.base=/home/deploy/tomcat/apache-tomcat-7.0.75-df
[deploy@df-prod deploy_wars]$ kill -9 31765 [deploy@df-prod deploy_wars]$ cd /home/deploy/deepFashion_targets/deploy_wars && sh /home/deploy/tomcat/apache-tomcat-7.0.75-df/bin/startup.sh Tomcat started.
[deploy@df-prod deploy_wars]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 6.2G 32G 17% / devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 432K 3.9G 1% /run