当前位置:网站首页>crontab定时任务输出产生大量邮件耗尽文件系统inode问题处理
crontab定时任务输出产生大量邮件耗尽文件系统inode问题处理
2022-04-23 13:51:00 【数语数行】
在某台Linux系统中运行命令,按tab键补充输出时,提示“无法为立即文档创建临时文件:设备上没有空间”信息,如下所示:

检查文件系统的空间使用情况,输出正常:

检查文件系统的inode数量使用情况,根分区的inode已经全部耗尽:

使用命令“ls -lR /var |grep “^-”|wc -l”查看根目录下各个目录的文件数量,发现/var目录有大量的文件。
进一步检查,确认/var/spool/postfix/maildrop目录下有大量的小文件。
"mailq"命令显示有大量的root用户待发送邮件队列,“mail”输出中也有大量的信息。
进入/var/spool/postfix/maildrop目录,删除目录下所有文件。
# find ./ -type f | xargs rm -f
或
# find ./ -type f -exec rm -f {} ;
根目录的inode使用情况恢复正常,如下:

同时,也对root用户收到的所有邮件进行了清空:
# echo > /var/spool/mail/root
检查系统中的crontab定时任务列表,其中含有每分钟执行一次的脚本,但脚本后面没有加上“ > /dev/null 2>&1”或者“ > 日志路径和名称 2>&1”来丢弃或保留脚本的输出到日志文件。
系统在默认情况下,会将crontab定时任务执行的脚本的输出通过邮件发送给cron用户。但是由于用户接收的邮件数量或邮件占用的总空间大小有最大限制,因此发送不成功的邮件就不断在/var/spool/postfix/maildrop目录下堆积,最终导致文件系统中文件数量过多而耗尽文件系统的inode。
标准的定时任务配置建议在脚本后面加上前面所述的内容。
另外,也可以使用crontab -e更改用户的定时任务,在脚本的前面行中加上行MAILTO=“”,让cron进程不将脚本输出的内容通过邮件来发送(如果使用/etc/crontab文件来配置MAILTO参数的话,定时任务脚本应该也得放在该文件中才能生效),示例如下:
# crontab -l
MAILTO=“”
* * * * * script1.sh
版权声明
本文为[数语数行]所创,转载请带上原文链接,感谢
https://blog.csdn.net/jetliu05/article/details/124342527
边栏推荐
- Two ways to deal with conflicting data in MySQL and PG Libraries
- 19c environment ora-01035 login error handling
- Leetcode brush question 897 incremental sequential search tree
- 3300万IOPS、39微秒延迟、碳足迹认证,谁在认真搞事情?
- UML统一建模语言
- Leetcode brush question 𞓜 13 Roman numeral to integer
- Dolphin scheduler source package Src tar. GZ decompression problem
- 服务器中挖矿病毒了,屮
- JS time to get this Monday and Sunday, judge the time is today, before and after today
- Oracle modify default temporary tablespace
猜你喜欢

Kettle--控件解析

Express ② (routing)

Double pointer instrument panel reading (I)

Apache Atlas Compilation and installation records

Dolphin scheduler scheduling spark task stepping record

聯想拯救者Y9000X 2020

SQL learning | complex query
![[VMware] address of VMware Tools](/img/0e/13f263bd69c8224f7c755258d94777.png)
[VMware] address of VMware Tools

SSM project deployed in Alibaba cloud

2021年秋招,薪资排行NO
随机推荐
Ora-16047 of a DG environment: dgid mismatch between destination setting and target database troubleshooting and listening vncr features
2021年秋招,薪资排行NO
UML Unified Modeling Language
Kettle--控件解析
At the same time, the problems of height collapse and outer margin overlap are solved
Information: 2021 / 9 / 29 10:01 - build completed with 1 error and 0 warnings in 11S 30ms error exception handling
leetcode--977. Squares of a Sorted Array
淘宝发布宝贝提示“您的消保保证金额度不足,已启动到期保障”
Storage scheme of video viewing records of users in station B
19c RAC steps for modifying VIP and scanip - same network segment
Basic SQL query and learning
Oracle view related
Detailed explanation of redis (Basic + data type + transaction + persistence + publish and subscribe + master-slave replication + sentinel + cache penetration, breakdown and avalanche)
第十五章 软件工程新技术
Django::Did you install mysqlclient?
[code analysis (1)] communication efficient learning of deep networks from decentralized data
GDB的使用
[code analysis (3)] communication efficient learning of deep networks from decentralized data
Interval query through rownum
redis如何解决缓存雪崩、缓存击穿和缓存穿透问题