当前位置:网站首页>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
边栏推荐
- Express中间件③(自定义中间件)
- Ora-600 encountered in Oracle environment [qkacon: fjswrwo]
- Solution: you have 18 unapplied migration (s) Your project may not work properly until you apply
- [code analysis (3)] communication efficient learning of deep networks from decentralized data
- Oracle modify default temporary tablespace
- Personal learning related
- 淘宝发布宝贝提示“您的消保保证金额度不足,已启动到期保障”
- [code analysis (7)] communication efficient learning of deep networks from decentralized data
- Two ways to deal with conflicting data in MySQL and PG Libraries
- Leetcode | 38 appearance array
猜你喜欢
【项目】小帽外卖(八)
Modify the Jupiter notebook style
MySQL [SQL performance analysis + SQL tuning]
Information: 2021 / 9 / 29 10:01 - build completed with 1 error and 0 warnings in 11S 30ms error exception handling
MySQL index [data structure + index creation principle]
淘宝发布宝贝提示“您的消保保证金额度不足,已启动到期保障”
MySQL [acid + isolation level + redo log + undo log]
Leetcode? The first common node of two linked lists
cnpm的诡异bug
Android interview theme collection
随机推荐
Special window function rank, deny_ rank, row_ number
Oracle modify default temporary tablespace
PG library to view the distribution keys of a table in a certain mode
Express ② (routing)
Set Jianyun x Feishu Shennuo to help the enterprise operation Department realize office automation
AttributeError: ‘dict‘ object has no attribute ‘iteritems‘
Analysis of redo log generated by select command
Publish custom plug-ins to local server
JS compares different elements in two arrays
ARGB transparency conversion
SQL learning | complex query
JS time to get this Monday and Sunday, judge the time is today, before and after today
Es introduction learning notes
Kettle--控件解析
MySQL and PgSQL time related operations
Test on the time required for Oracle to delete data with delete
Storage scheme of video viewing records of users in station B
Analysis of unused index columns caused by implicit conversion of timestamp
Tersus notes employee information 516 MySQL query (time period uniqueness judgment of 2 fields)
[code analysis (7)] communication efficient learning of deep networks from decentralized data