Ubtunu checks whether the disk space is full - and the way to clean it

Project scenario:

Recently, the back-end project developed using nodejs was deployed to the Ubtunu server, and the interface could not be accessed, and the interface could not be called, and NGINX reported a 502 error.


 

Problem Description

Using the remote connection tool to transfer files also fails to upload, prompting that the file cannot be found, and the SCP command cannot be uploaded.

When scp transfers a file, an error is reported, indicating No such file or directory.


Cause Analysis:

Finally, after investigation, it was found that the disk space of the server was occupied by the pm2 log.


solution:

Use the command to scan the entire system for large files, delete logs

Use the command df to check whether the disk still has storage space

If the storage space is insufficient, use the find command to find large files

Delete large files (Delete needs to confirm whether it can be deleted, generally log files and installation packages can be deleted)

1. To view all disk information use the command: df -h

df -h

 

Display content parameter description:

Filesystem: File system
Size: Partition size
Used: Used capacity
Avail: Available capacity
Use%: Used percentage
Mounted on: Mount point
Related commands:

df -hl: check the remaining disk space
df -h: check the partition size of each root path
du -sh [directory name]: return the size of the directory
du -sm [folder]: return the total M number of the folder
du - h [directory name]: View all file sizes under the specified folder (including subfolders)

2. Command to view large files: find / -size +1G (represents finding all files larger than 1G from the root directory, others: +100M represents larger than 100M, -100M represents less than 100M. It is recommended to execute under root authority, execution may be a bit slow, need to wait for execution to complete)

find / -size +1G

 

3. Go to the corresponding directory through the path displayed by the search result, delete the file or clear the content of the file (you need to confirm whether it can be deleted before deleting, and the general log file can be deleted), and then part of the storage space can be released

rm -rf xxx.zip

references:

1. linux command to view disk space

2. Linux checks that the disk memory is full--clear memory method_qq_33173256's blog-CSDN blog_linux to check whether the memory is full 

3、PM2 - Logs 

Guess you like

Origin blog.csdn.net/qq_35624642/article/details/128159962