Home  >  Article  >  System Tutorial  >  How to solve the problem when the temp folder is suddenly full? Analysis of the problem that the tmp folder takes up 100%

How to solve the problem when the temp folder is suddenly full? Analysis of the problem that the tmp folder takes up 100%

WBOY
WBOYforward
2024-02-12 10:51:081033browse

php editor Apple will analyze for you "How to solve the problem that the temp folder is suddenly full? Analysis of the problem that the tmp folder takes up 100%". When the temp folder is suddenly full and the tmp folder is 100% occupied, it may be caused by too many temporary files in the system or application. Solutions include manually cleaning temporary files, checking whether there are program errors that prevent files from being deleted, modifying temporary file storage paths, setting automatic cleaning policies, etc. By taking appropriate measures, you can effectively solve the problem of the temp folder taking up too much disk space and ensure the normal operation of the system.

Tmp folder occupies 100% problem analysis

1. Check the disk usage through df -h and find that /dev/vdb1 (file storage path) occupies 42%, which is sufficient space; but /tmp The folder occupancy rate is 100%.

df -h

Part of the space has been released here, so /tmp occupies 91%.

How to solve the problem when the temp folder is suddenly full? Analysis of the problem that the tmp folder takes up 100%

#2. Enter the /tmp path to check the occupancy. It is found that the file occupancy is only 5.7M, and the actual total space is 16G.

cd /tmp

How to solve the problem when the temp folder is suddenly full? Analysis of the problem that the tmp folder takes up 100%

3. Since tmp is a temporary folder, the file is automatically deleted after use. It is speculated that the file is deleted but the space is not released. Condition. Check the file status through lsof /tmp and find that a large number of files have been deleted but are still occupied by processes, resulting in the inability to free up space.

lsof /tmp

How to solve the problem when the temp folder is suddenly full? Analysis of the problem that the tmp folder takes up 100%

4. The process PID of the file occupied by the above screenshot is 3860289, which is an undeployed springboot project. Under normal circumstances, restarting the project can release it, but it is currently an online project, and restarting it will affect user use. Therefore, it is necessary to free up space without restarting.

Solve the problem

1. Query the file fd information of the process occupied by the file ls -i /proc/{process PID}/fd For example:

ls -i /proc /3860289/df

How to solve the problem when the temp folder is suddenly full? Analysis of the problem that the tmp folder takes up 100%

##2. Release the space occupation through >/proc/{process pid}/fd/{file fd} (the file fd is the red part in the above picture) first number), for example:

>/proc/3860289/fd/999

3. Batch release of file occupation can be solved by writing a shell script. For example: delete pid as Files with fd between 500 and 1000 are occupied in 3860289.

#! /bin/bash

for i in {500..1000}

do

/proc/3860289/fd/$i

done

4. The above is occupied by temporary deletion of files. Finally, the problem can be solved by restarting the application kill -9 {PID}

kill -9 3860289

The above is the detailed content of How to solve the problem when the temp folder is suddenly full? Analysis of the problem that the tmp folder takes up 100%. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:xpwin7.com. If there is any infringement, please contact admin@php.cn delete