奇诺分享 | ccino.org

  • 首页
  • VPS
    • VPS申请
    • VPS配置
    • 科学上网
  • 网站建设
    • WordPress
  • 程序猿
    • 开发工具
    • 微服务
    • 容器
    • 分布式
    • 数据库
  • 杂项
  • 关于
  • Privacy Policy
生活不只是眼前的苟且,还有诗和远方!
  1. 首页
  2. VPS
  3. 正文

linux内存大量sendmail、postdrop进程占用

2022年4月6日 657点热度 1人点赞 0条评论

linux环境32G内存,used 28G,其实并没有什么用户进程,占用也不大

  1. 使用echo 1 > /proc/sys/vm/drop_caches、echo 3 > /proc/sys/vm/drop_caches释放内存都没多大效果,说明内存确实分配到进程了
  2. 使用ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid'查看进程详细信息,发现存在大量sendmail、postdrop进程,虽然单个占用内存不多,但是量太大了
  3. killall sendmail & killall postdrop先杀掉进程,内存占用瞬间降低到2G,说明是这个原因
  4. 查问题原因,解决

 

原文:cnblogs.com/skyaccross/archive/2013/03/21/crond_sendmail.html

今天一位同事说一个服务器common账号登陆不进去,说是资源耗尽,要我帮忙检查一下
我用另一个账号登陆到服务器,首先我想看看common账号到底启动了哪些dd引起资源耗尽

ps -u common

发现有个 sendmail的启动特别多
例如

common   31446 31377  0 20:20 ?       /usr/sbin/sendmail -FCronDaemon -i -odi -oem -oi -t -f root

鉴于资源耗尽,留下证据后,先杀掉,保证生产

ps -ef|grep "/usr/sbin/sendmail"|grep -v grep |awk '{print $2}'|xargs kill

然后检查是哪个进程启动了sendmail

ps -ef|grep 31337

发现是crond启动了,当时就奇怪了,这个进程怎么会调用sendmail
既然是crond启动的,而之前一直好好的,于是询问最近谁修改了crond
得知有一位同事添加了 一个crond记录,一分钟运行一次
这时查看sendmail进程
ps -ef|grep sendmail
果然又有了,而且sendmail是1分钟启动一个。果断的怀疑他,将它从crontab暂停,2分钟过去
没有新的sendmail启动,于是将问题就锁定在它身上了。

也没有想到原因,为啥crond会调用sendmail,google之找到了这样一句

crond在执行脚本时会将脚本输出信息以邮件的形式发送给crond用户,而环境的postfix没有正常运行,导致邮件发送失败
查看我们的 maillog,确实有很多错误

postfix/postdrop[23110]: warning: mail_queue_enter: create file maildrop/749274.23110: No such file or directory

解决方法就是
在crontab中第一行增加MAILTO=""发送为空

如果cron有什么原因需要将命令结果发一封邮件,那么就要看MAILTO这部分了,如果给MAILTO赋值了,并且不是空,那么就会发给这个用户;
如果是空,MAILTO="",那就不发任何邮件。
如果没有定义MAILTO,也就是说crontab里面没有写这一行,那么就发给这个crontab的用户
原文如下

复制代码

man 5 crontab
    In  addition  to  LOGNAME,  HOME, and SHELL, cron(8) will look at MAILTO if it has any reason to send
 mail as aresult of running commands in "this" crontab.  If MAILTO is defined (and non-empty), mail is 
sent to  the  userso  named.   If  MAILTO  is defined but empty (MAILTO=""), no mail will be sent.  
Otherwise mail is sent to the owner of the crontab.  This option is useful if you decide on /bin/mail
 instead of  /usr/lib/sendmail  as  your mailer when you install cron -- /bin/mail doesn′t do aliasing, 
and UUCP usually doesn′t read its mail. If MAIL-FROM is defined (and non-empty), 
it will be used as the envelope sender address, otherwise,  ‘‘root’’  will  be used.

复制代码

我们这个不需要发邮件,于是 在crontab 第一行加上 MAILTO=""
观察了两分钟,问题解决。

 

原文:https://blog.csdn.net/liang100k/article/details/53635344

问题:服务器内存接近耗尽报警,ps -ef查看有3000多个进程,大部分都是crond、sendmail、postdrop

而 postdrop是由sendmail启动的,而sendmail又是由crond启动的。

 

问题成因:crond在执行脚本时会将脚本输出信息以邮件的形式发送给系统用户,所以必然要调用sendmail,而sendmail又会调用postdrop发送邮件,但是如果系统的postfix服务没有正常运行,那么邮件就会发送不成功,造成sendmail、postdrop、crond进程就无法正常退出,形成大量的僵尸进程

 

解决办法:先把僵尸进程都干掉ps -ef | egrep "sendmail|postdrop" | grep -v grep |xargs kill,让内存降下来,其实我一开始将postfix服务重启了一下,问题就解决了,观察了一段时间,僵尸进程并没有再次出现。

为防以后postfix挂了再出现类似问题,可以进行如下配置,将crond的邮件通知关闭:

将/etc/crontab和/etc/cron.d/0hourly里的MAILTO=root修改为MAILTO=""

crontab -e第一行增加一段MAILTO=""

 

原文:http://blog.itpub.net/29071259/viewspace-1427129/

原因:

crontab 如果有错误,没有重定向,需要输出到屏幕时。就会产生 /usr/sbin/sendmail

产生如下的多个进程:
[cron]
[backup_db_cront]
/usr/sbin/sendmail -FCronDaemon -i -odi -oem -oi -t -f root
/usr/sbin/postdrop -r

查看邮件日志:
cd /var/spool/postfix/maildrop

查看60分钟内的log
find . -mmin -60

找出错误所在。

相关文章

  • Linux流量监控工具 - iftop

  • 在这里插入图片描述

    CentOS7防火墙之firewall-cmd命令详解

  • esxi6.0-6.7下添加USB硬盘作为数据存储

  • 宝塔面板python项目管理器部署netease-cloud项目创建失败,解决方法

  • python2.7.5升级Python3.8.0

标签: 暂无
最后更新:2022年4月6日

奇诺分享 | ccino.org

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据。

COPYRIGHT © 2022 奇诺分享 | ccino.org. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang