标题:[实践OK]由于crondtab定时任务导致大量sendmail进程的解决办法 出处:向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除 时间:Mon, 01 Jan 2018 14:49:39 +0000 作者:jackxiang 地址:http://jackxiang.com/post/9585/ 内容: 背景:Zabbix报警进程数太多报警Too many processes on servername ...。发现是Sendmail进程数太多。 ps -ef|grep sendmail|wc -l 569 -bash: /data/logs/.syshistory/bash_history.log: Read-only file system /usr/sbin/postdrop -r /usr/sbin/sendmail -FCronDaemon -i -odi -oem -oi -t -f root [aio/21] [kblockd/18] [kondemand/0] [kondemand/1] [kondemand/N] 执行top的时候发现当前用户下面有很多sendmail的进程,如下图所示,发件人是crondaemon,怀疑是和定时任务有关,查看当前用户的定时任务发现有一个每分钟运行一次的定时任务,但是定时脚本是没有调用sendmail了,ps -ef | grep sendmail | wc -l 统计发现sendmail的进程数据基本上就是从服务器出故障到当前时间的分钟数。 /usr/sbin/sendmail -FCronDaemon -i -odi -oem -oi -t -f root /usr/sbin/sendmail -FCronDaemon -i -odi -oem -oi -t -f root /usr/sbin/sendmail -FCronDaemon -i -odi -oem -oi -t -f root 然道是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="" From:http://blog.51cto.com/chenql/1878182 Generated by Jackxiang's Bo-blog 2.1.1 Release