Why and var and spool and postfix and maildrop takes up so much space in Linux

  • 2020-05-27 08:00:58
  • OfStack

Found the problem

Recently, I found an error in my work. MySQL reported an error Exception Message:SQLSTATE[08004][1040]Too many connections After checking the error is caused by the disk space full, so find 1 can delete some files to make 1 space.

The reason that space takes up big

Find/var/spool/postfix/maildrop this directory occupies more than six G space, online to find one kind of problem, the reason is:

Because Linux when performing cron, will cron output in executing scripts and warning information, will be in the form of mail sent cron owner, and due to the customer in the environment sendmail and postfix did not run normally, lead to mail delivery is not successful, all small files piling up in maildrop directory below, and there is no automatic cleaning conversion mechanism, so 1 years of time, this directory has accumulated a large number of documents. Check the man cron information to see if it will be sent to cron owner.

Try to delete the contents of this directory, but execute rm -rf ./* It was prompted that the parameter list was too long and was later deleted using the following command:

ls | xargs rm -f

Delete by pipeline.

The script redirects the output

So note that the crontab script outputs content to the log, or /dev/null 2 > & 1. Avoid creating a large number of unnecessary files.

Several Linux commands to find files and Spaces

find . -type f -size +1000000k Find large files and directories

du -s * | sort -nr | head Displays the top 10 files or directories that take up the most space

du -sh * Traverse the directory size

df -hl System mount hard disk space size


Related articles: