Linux Tip

disk full 상태 인데 du로 때려봐도 추적이 안돼면..

hangrum 2021. 7. 12. 00:14
root@focal:~# ps aux |grep metric
root         726  2.1  0.1 1851764 95796 ?       Ssl  Jul08 106:30 /usr/share/metricbeat/bin/metricbeat 

root@focal:~# lsof -p 726
COMMAND   PID USER   FD      TYPE             DEVICE  SIZE/OFF    NODE NAME
metricbea 726 root  cwd       DIR                8,1      4096       2 /
metricbea 726 root  rtd       DIR                8,1      4096       2 /
metricbea 726 root  txt       REG                8,1 124485568 1284299 /usr/share/metricbeat/bin/metricbeat
metricbea 726 root  mem       REG                8,1    239896    2502 /usr/lib/x86_64-linux-gnu/libnss_systemd.so.2
metricbea 726 root  mem       REG                8,1     51832    4660 /usr/lib/x86_64-linux-gnu/libnss_files-2.31.so
metricbea 726 root  mem       REG                8,1   2029224    4639 /usr/lib/x86_64-linux-gnu/libc-2.31.so
metricbea 726 root  mem       REG                8,1     18816    4640 /usr/lib/x86_64-linux-gnu/libdl-2.31.so
metricbea 726 root  mem       REG                8,1    157224    4665 /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
metricbea 726 root  mem       REG                8,1    191472    3430 /usr/lib/x86_64-linux-gnu/ld-2.31.so
metricbea 726 root    0r      CHR                1,3       0t0       6 /dev/null
metricbea 726 root    1u     unix 0xffff98d451dd1800       0t0   21698 type=STREAM
metricbea 726 root    2u     unix 0xffff98d451dd1800       0t0   21698 type=STREAM
metricbea 726 root    3w      REG                8,1    785755  774343 /var/log/metricbeat/metricbeat
...

해당 프로세스가 쓰는 소켓, 파일등을 보는 lsof -p <pid>를 치면 위와 같이 나오게 된다.

그중 (delete) 로 표시되는 파일을 grep 해보면 

sh      25626 root   10u   REG  202,1 21280244045     773 /tmp/tmpfZ14vFH (deleted)

위와 같이 나오게 된다.

해당 프로세스를 확인(ps aux|grep <pid>)하고 재시작 하면 된다.

 

출처: https://serverfault.com/questions/881501/lsof-shows-tmp-growing-file-marked-as-deleted

 

lsof shows tmp growing file marked as deleted

I have a cron that generated a lot (15GB) of PHP warnings and was writing them in a log file. I killed the process and as a temporary measure I stopped redirecting stderr to stdout so I don't fill...

serverfault.com