惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
GbyAI
GbyAI
C
Check Point Blog
M
MIT News - Artificial intelligence
T
The Blog of Author Tim Ferriss
Jina AI
Jina AI
博客园 - 【当耐特】
U
Unit 42
月光博客
月光博客
腾讯CDC
Y
Y Combinator Blog
小众软件
小众软件
博客园_首页
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
博客园 - 聂微东
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
T
Tailwind CSS Blog

膨胀自留地

使用CloudFlare标记管理功能优雅的使用谷歌分析 四天轻松版北京旅游攻略 Adsense税务居住地证明申请教程:如何申请中国税收居民身份证明以及Google Adsense更新新加坡税务信息教程 常见的 VPS 优化措施 HTML实现table表格移动端自动转为卡片样式 个人网站接入 Google 登录 如何从 GitHub 永久删除泄露的 .env 文件 Cloudflare设置www的域名跳转到不带www的域名 顶级iOS神器!全面解开App Store限制,AssPP Pro保姆级教程 BroadcastChannel将你的 Telegram Channel 转为微博客 Medama开源轻量级网站统计(分析)系统 白嫖一个网站监控面板:uptime-kuma 部署TraffMonetizer利用闲置VPS挂机赚钱 Counterscale-使用CloudflareWorkers部署的免费网站数据统计工具,界面类似umami 封装一个最简单的Axios,避免过度封装! 如何使用Cloudflare Email Routing创建域名邮箱免费发送邮件 使用Cron定时更新Hosts解决Gihub无法访问问题 容器化MariaDB/Mysql实现定时备份 JetBrains全家桶许可证服务器怎么找,JetBrains激活教程 图片加速接口:缓存图片,加速访问,解决防盗链 MySQL模糊查询再也不用like+%了,全文索引介绍及使用简介 为什么这么多人推荐你办理流量卡?流量卡怎么赚钱?怎么避坑? 借助Cloudflare Worker实现Google Analytics反代加速,规避广告屏蔽插件的拦截 etcd入门之在Centos上安装部署 Grafana在linux下安装和基本使用入门 Prometheus介绍、安装和基本功能快速入门 无需加速器,油猴插件解锁xbox云游戏 阿里云盘自动每日签到,无需部署,无需服务器 自定义VSCode终端主题样式 一行 CSS 代码实现响应式布局 – 使用 Grid 实现的响应式布局
crond 引发大量 sendmail 进程的解决办法
2021-01-19 · via 膨胀自留地

#编程技术 2021-01-19 16:34:00 | 全文 586 字,阅读约需 2 分钟 | 加载中... 次浏览

👋 相关阅读


发现问题

这两天看到几台服务器比较异常,平常流量跑满,突然就没有了流量,TCP 连接也没了。于是登录上服务器查看,首先想重启 nginx 服务,结果报错,大致意思就是磁盘空间已满。通过 df -h 命令查看,发现各个分区还有很充足的空间,然后 df -i 一看,发现分区 inode 已经满了。

定位问题

第一反应是 /var 目录下的文件导致,于是用下面脚本找出 /var 下各个目录文件数量,逐步定位到 /var/spool/postfix/maildrop

#!/bin/sh
find /var/ -maxdepth 1 -type d | while read dir; do 
    count=$(find "$dir" -type f | wc -l)
    echo "$dir : $count"
done

找到目标,首要就是先杀掉这里面的大量文件,三十多万文件。采用 rsync 同步清除,效率比较快。

在其他分区创建空目录:

// 杀死所有 sendmail 和 postdrop 进程
ps -e | grep sendmail | cut -d ' ' -f2 | xargs kill
ps -e | grep postdrop| cut -d ' ' -f2 | xargs kill

mkdir -p /home/a.test
rsync -av --delete /home/a.test/  /var/spool/postfix/maildrop/

查看其他错误日志,发现都是 crond 引发的 sendmail

du -sh 查看找到了一个巨大的文件 /var/log/mailog 。head、tail 查看内容,发现全是同样的内容行,如下:

May 2 5:29:23 lcha2 postfix/postdrop[1443]: warning: mail_queue_enter: create file maildrop/383480.1443: No such file or directory
May 2 5:29:23 lcha2 postfix/postdrop[1269]: warning: mail_queue_enter: create file maildrop/330426.1269: No such file or directory
May 2 5:29:23 lcha2 postfix/postdrop[1439]: warning: mail_queue_enter: create file maildrop/357169.1439: No such file or directory
May 2 5:29:23 lcha2 postfix/postdrop[1654]: warning: mail_queue_enter: create file maildrop/984222.1654: No such file or directory

解决方法:

1、 修改邮件日志输出条件

vim /etc/rsyslog.conf

找到 mail.*

改成 mail.err

2、 在 crontab 中第一行增加 MAILTO="" 发送为空

MAILTO=""

3、将 /etc/crontab 中的 MAILTO 改为 ""

4、将 /etc/postfix/main.cf 配置文件中,inet_protocols = all 改为 inet_protocols = ipv4

5、 crond 执行的命令最后加上 &> /dev/null

via

crond 引发大量sendmail进程的解决办法 - Yun维攻城狮 http://www.89cool.com/411.html Crontab导致Linux文件描述符枯竭-king_wangheng-ChinaUnix博客 http://blog.chinaunix.net/uid-26896862-id-3809084.html


×