当前位置:网站首页>Crontab timing task output generates a large number of mail and runs out of file system inode problem processing

Crontab timing task output generates a large number of mail and runs out of file system inode problem processing

2022-04-23 13:53:00 Number line language

In a certain station Linux Run commands in the system , Press tab Key supplementary output , Tips “ Unable to create temporary file for immediate document : There's no room on the device ” Information , As shown below :
 Insert picture description here
Check the space usage of the file system , Normal output :
 Insert picture description here
Check the file system inode Quantity usage , Root partition inode It's all exhausted :
 Insert picture description here
Use command “ls -lR /var |grep “^-”|wc -l” Check the number of files in each directory under the root directory , Find out /var There are a lot of files in the directory .

Further inspection , confirm /var/spool/postfix/maildrop There are a lot of small files in the directory .

"mailq" The command shows a large number of root User to send mail queue ,“mail” There is also a lot of information in the output .

Get into /var/spool/postfix/maildrop Catalog , Delete all files in the directory .
# find ./ -type f | xargs rm -f
or
# find ./ -type f -exec rm -f {} ;

Root directory inode The service condition returns to normal , as follows :
 Insert picture description here
meanwhile , Also on the root All emails received by the user have been emptied :
# echo > /var/spool/mail/root

Check the system for crontab Scheduled task list , It contains scripts that execute every minute , But the script didn't add “ > /dev/null 2>&1” perhaps “ > Log path and name 2>&1” To discard or retain the output of the script to the log file .

By default , Will crontab The output of the script executed by the scheduled task is sent to cron user . However, due to the maximum limit of the number of emails received by users or the total space occupied by emails , So sending unsuccessful emails is constantly /var/spool/postfix/maildrop Stack under directory , Eventually, the number of files in the file system is too large and the capacity of the file system is exhausted inode.

Add the content of the above standard configuration script .

in addition , You can also use crontab -e Change the user's scheduled task , Add a line to the front line of the script MAILTO=“”, Give Way cron The process does not send the output of the script by mail ( If you use /etc/crontab File to configure MAILTO Parameter words , The scheduled task script should also be placed in this file to take effect ), Examples are as follows :
# crontab -l
MAILTO=“”
* * * * * script1.sh

版权声明
本文为[Number line language]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231351026603.html