As less proficient in operations of a normal Java programmer, maintains a dozen Java project of the project, and then just know a little ops, suddenly one day disk usage rate is 92%, and then continues to rise, then small make up a bit of a panic, after take full will down machine, for the active volume 4 w small server users per hour, There will be a lot of panic….

The first step in logging in to the server using SSH is to view the mount information. The df command in Linux is used to check disk space usage of the file system on the Linux server.

[root@service-1 /]# df -lThe file system1K- Block used Available Used % mount point /dev/vda151473020 44196756  4638548   91% /
devtmpfs       16380572        0 16380572    0% /dev
tmpfs          16390076        0 16390076    0% /dev/shm
tmpfs          16390076      796 16389280    1% /run
tmpfs          16390076        0 16390076    0% /sys/fs/cgroup
tmpfs           3278016        0  3278016    0% /run/user/0

Copy the code

Step 2 Check directory usage

[root@service-1 /]# du -h --max-depth=1
0       ./sys
0       ./dev
110M    ./tmp
48M     ./root
21G     ./opt
4.0K    ./media

Copy the code

My opt directory occupies a large amount of space. Then I go to the opt directory and continue to check the usage of each directory

[root@service-1 /]# cd opt
[root@service-1 opt]# ls
learncoal-services  learncoal-services-test  learncoal-webapps  new  prod-tools
[root@service-1 opt]# du -h --max-depth=1
876M    ./learncoal-webapps
428M    ./prod-tools
67M     ./new
462M    ./learncoal-services-test
20G     ./learncoal-services
21G     .

Copy the code

Learncoal-services directory is used by files in the directory. The directory is used by files in the directory

[root@service-1 opt]# cd learncoal-services
[root@service-1 learncoal-services]# du -sh ./*
4.0K    ./a.sh
12G     ./consoleMsg.log
8.0K    ./data
71M     ./learncoal-service-api- 2021..- 23- 01.jar
71M     ./learncoal-service-api- 2021..- 23..jar
71M     ./learncoal-service-api- 2021..- 23- 03.jar
13M     ./log
4.0K    ./start_info.sh
4.0K    ./start.sh
4.0K    ./start_x.sh
77M     ./toupiao-service-api73.jar
77M     ./toupiao-service-api74.jar
77M     ./toupiao-service-api75.jar
1.2M    ./tplfile

Copy the code

Consolemsg. log takes up 12 gigabytes. Delete the log file. Looking back, it turned out that more than n days ago xiaobian did several tests, Java process memory leakage caused by, so I looked at the Java process occupancy situation

[root@service-1 learncoal-services]# ps -ef|grep java|grep -v grep
Copy the code

All processes other than the red line are leaking processes and can be killed

[root@service-1 learncoal-services]# kill 25878.Copy the code

After finishing