由于crondtab定时任务导致大量sendmail进程的解决办法

早上六点多钟有一台服务器告警说宕机了,尝试登陆发现登陆服务器没问题,ps -ef | grep mysql的时候发现mysqld服务也还在,mysql错误日志也没有任务报错。但是查看vim /var/log/messages时发现是硬盘有问题,尝试touch一个文件的时候提示‘read-only file system’,于是联系机房检测故障。


但是当执行top的时候发现当前用户下面有很多sendmail的进程,如下图所示,发件人是crondaemon,怀疑是和定时任务有关,查看当前用户的定时任务发现有一个每分钟运行一次的定时任务,但是定时脚本是没有调用sendmail了,ps -ef | grep sendmail | wc -l 统计发现sendmail的进程数据基本上就是从服务器出故障到当前时间的分钟数。

wKiom1g-kpHwupKwAAC83P5yQLw090.png-wh_50


然道是crontab每次执行都会调用sendmail发邮件吗?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 a result of running commands in "this" crontab.  If MAILTO is defined (and non-empty), mail is sent to the user so 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 doesnt do aliasing, and UUCP usually doesnt read its mail. If MAILFROM is defined (and non-empty), it will be used as the envelope sender address, otherwise, ‘‘root’’ will be used.



查看crontab的配置文件:

cat /etc/crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/


可以看到MAILTO这一行不为空,如果不想让它发邮件的话可以按照手册上面说的把MAILTO这一行删掉或者改为MAILTO=""




本文转自 emma_cql 51CTO博客,原文链接:http://blog.51cto.com/chenql/1878182
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值