On the Linux server, the system prompts "No space left on device". How can this problem be solved?

Source: Internet
Author: User

On the Linux server, the system prompts "No space left on device". How can this problem be solved?
Cause

I submitted some code locally today, but the system prompts No space left on device when I go to git pull on the Linux server, the first reaction is to guess that the hard disk may be full (probably caused by logs), but I think it is unlikely that only one application is deployed on this server, and the project space is not large.

Solution Process

1. As a linux cainiao, Baidu immediately queries the command about checking hard disk usage

Root@www.bkjia.com ~ # Df-h
File System capacity used available % mount point
/Dev/hda1 20G 2.4G 18G 13%/
Tmpfs 1006 M 0 1006 M 0%/dev/shm

The content shown above is after solution. Because the terminal has been closed, the phenomenon before solution cannot be reproduced, and the content of the second line is basically displayed, the line is not underlined before the resolution. At that time, I was thinking about WTF.

2. As a result, the command df/home was accidentally displayed.

Root@www.bkjia.com ~ # Df/home
File System 1 K-block used available % mount point
/Dev/hda1 20802016 20798393 3623 100%/

I finally found out that this product had a usage of 100% as expected, but I still don't know which files caused it. So I checked it with my O & M brother.

3. The O & M brother was very good. In a moment, he found a dangerous horse.

[root@iZ23nce0j6gZ ~]# ll -ah
-rw-r--r--  1 root root 20G 06-08 10:38 test.log

Hey, what's in the slot? The Ghost occupies 20 GB. Open the html code of Baidu and find it. Is it a crawler log?

4. check who is writing the file.

[root@www.bkjia.com ~]# lsof test.log

This command can only display the content when the file is written. Although a process number is obtained, it is closed because the process is finished and cannot be found.

5. All of a sudden, I suddenly wrote a test crontab timing script.

[root@www.bkjia.com ~]# crontab -l*/1 * * * * /usr/bin/curl http://www.baidu.com >> /root/test.log 2>&1

It is indeed it, it is it, it is it ~

6. Delete the test. log File and stop the script.

Ps: After the problem is solved, the O & M brother also uses the netstat-utlpn | grep 2 command to scan the ports opened on the server. We recommend that you change these default ports, because many hackers scan these ports, there are security risks.

Summary

This is mainly a self-built Oolong event. After the test, the scheduled script is not stopped in time, resulting in the log being fully occupied by the hard disk.

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.