根据cron(8)(实际发送消息的守护程序)的手册页:
-m This option allows you to specify a shell command string to use for
sending cron mail output instead of sendmail(8). This command must
accept a fully formatted mail message (with headers) on stdin and send
it as a mail message to the recipients specified in the mail headers.
这使我相信默认情况下使用的是sendmail。让我们用strace进行验证:
设置将生成电子邮件的cron作业:
user@host1 ~:
$ crontab -e
crontab: installing new crontab
user@host1 ~:
$ crontab -l
MAILTO=example@example.com
*/5 * * * * echo "testing"
现在找到crond的进程ID:
user@host1 ~:
$ ps auxww | grep crond
root 9684 0.0 0.0 117280 1296 ? Ss Jul22 0:17 crond
user 36344 0.0 0.0 103240 884 pts/2 S+ 23:01 0:00 grep crond
使用strace附加到crond进程,查找与进程相关的活动。当strace写入stderr时,我已将其重定向到stdout并grepped为'mail':
root@host1 ~:
# strace -fp 9684 -s 1024 -e trace=process 2>&1 | grep mail
[pid 36204] execve("/usr/sbin/sendmail", ["/usr/sbin/sendmail", "-FCronDaemon", "-i", "-odi", "-oem", "-oi", "-t", "-f", "root"], [/* 16 vars */]) = 0
^C
是的,这是sendmail。