Lsof command usage: view processes that have deleted space but not released
Check the deleted files to see if the space has been freed. If not, kill and pid.
Lsof-n | grep deleted
About lsof lsof (list open files) is a tool that lists files currently open on the system.
Problem description:
The service alarms that the utilization rate of the root partition is more than 95%. Check up and find that the utilization rate is 96%.
However, in the directory under / partition, each query adds up to less than 4G space, so I don't know where the extra 40G is?
Find query also did not find large files.
Analyze the reasons:
It may be that the space occupied by the system process is not released.
Through the command inspection, it is found that there are a total of three php processes, all of which are in deleted state, and the file size is exactly 40G, which is exactly the extra space to find the problem.
Solution:
Find the corresponding php process number and drop it by kill.
[root@host127 WebServer] # lsof-n / | grep deletedmysqld 2660 mysql 4U REG 8deleted 20 524290 / tmp/ibSF7sXt (deleted) mysqld 2660 mysql 5u REG 8mysqld 2 524305 / tmp/ibCCM4u4 (deleted) mysqld 2660 mysql 6u REG 8deleted 20 524309 / tmp/ibKuAG2E (deleted) mysqld 2660 mysql 7u REG 8deleted 20524315 / tmp/ibcLe4Bf (deleted) mysqld 2660 Mysql 11u REG 8 2 0 524316 / tmp/ibW2n1iQ (deleted) php 7045 root 0r REG 8 REG 2 1172 524374 / tmp/sh-thd-1494029191 (deleted) php 7045 root 2w REG 8 42413952626 657428 / var/spool/at/spool/a0100c017bf37c (deleted) php 7054 root 0r REG 8leg2 1172 524374 / tmp/sh-thd-1494029191 (deleted) php 7054 root 2w REG 8maire2 42413952626 657428 / var/spool/at/spool/a0100c017bf37c (deleted) php 12730 root 0r REG 8Let2 1172 524374 / tmp/sh-thd-1494029191 (deleted) php 12730 root 2w REG 8Lie2 42413952626 657428 / var/spool/at/spool/a0100c017bf37c (deleted) mysqld 17855 mysql 4u REG 8MIT 2 0524384 / tmp/ibxBS5jf (deleted) mysqld 17855 mysql 5u REG 8Jue 2 0524385 / tmp/ibmrNzfL (deleted) mysqld 17855 mysql 6u REG 8 REG 2 524386 / tmp/ibVDS3ah (deleted) mysqld 17855 mysql 7u REG 8 2 524387 / tmp/ibx6YTrj (deleted) mysqld 17855 mysql 13u REG 8 2 524388 / tmp/ibOhb8xQ (deleted)
No files were found in the corresponding directory
[root@host127 WebServer] # ll / var/spool/at/spool/
Total dosage 0
[root@host127 WebServer] # kill-9 7045
[root@host127 WebServer] # kill-9 7054
[root@host127 WebServer] # kill-9 12730
Look again at the process that found no php
[root@host127 WebServer] # lsof-n / | grep deleted
Mysqld 2660 mysql 4U REG 8pm 2 524290 / tmp/ibSF7sXt (deleted)
Mysqld 2660 mysql 5u REG 8pm 2 524305 / tmp/ibCCM4u4 (deleted)
Mysqld 2660 mysql 6u REG 8pm 2 524309 / tmp/ibKuAG2E (deleted)
Mysqld 2660 mysql 7u REG 8pm 2 524315 / tmp/ibcLe4Bf (deleted)
Mysqld 2660 mysql 11u REG 8 Magi 2 524316 / tmp/ibW2n1iQ (deleted)
Mysqld 17855 mysql 4U REG 8pm 2 524384 / tmp/ibxBS5jf (deleted)
Mysqld 17855 mysql 5u REG 8pm 2 524385 / tmp/ibmrNzfL (deleted)
Mysqld 17855 mysql 6u REG 8pm 2 524386 / tmp/ibVDS3ah (deleted)
Mysqld 17855 mysql 7u REG 8pm 2 524387 / tmp/ibx6YTrj (deleted)
Mysqld 17855 mysql 13u REG 8 Magi 2 524388 / tmp/ibOhb8xQ (deleted)
Check that the space has been restored:
[root@host127 WebtServer] # df-h File system capacity available used% mount point / dev/sda2 49G 4.4G 42G 10% / tmpfs 16G 0 16G 0% / dev/shm