AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 115790
Accepted
benjisail
benjisail
Asked: 2010-02-24 06:32:02 +0800 CST2010-02-24 06:32:02 +0800 CST 2010-02-24 06:32:02 +0800 CST

MAILTO 不适用于 CRON。我怎样才能解决这个问题?

  • 772

我已经为 root 用户设置了 cronjob。但是,当 cron 失败时,我应该会收到来自 cronjob 的电子邮件,因为我在 /etc/crontab 中设置了 MAILTO,如下所示:

[email protected]

我已经使用安装了mailx

yum install mailx

但是当我查看 cron 日志时,我得到以下几行:

Feb 23 14:13:01 internal crond[6858]: (root) CMD (/var/www/vded/build/bin/sync.sh)
Feb 23 14:13:01 internal crond[6857]: (root) MAIL (mailed 79 bytes of output but got status 0x0001 )

我怎样才能解决这个问题?

更新 :

  • 我使用 yum 安装了 mailx 和 sendmail。
  • 我开始发送邮件。
  • 所以现在可以从命令行发送电子邮件了!

我在邮件日志中收到此错误:

Feb 23 16:06:01 internal sendmail[7210]: o1NG61cd007210: from=root, size=425, class=0, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
Feb 23 16:06:01 internal sendmail[7211]: o1NG61hT007211: from=<[email protected]>, size=732, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Feb 23 16:06:01 internal sendmail[7210]: o1NG61cd007210: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30425, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o1NG61hT007211 Message accepted for delivery)
Feb 23 16:06:01 internal sendmail[7212]: o1NG61hT007211: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30972, dsn=2.0.0, stat=Sent

internal.fff.com 是服务器的名称。

更新 :

所以事实上,如果我把它[email protected]作为我的 crontab 的第一行(使用crontab -e)它正在工作。

MAILTO为什么设置in不起作用/etc/crontab?

谢谢

email cron
  • 3 3 个回答
  • 38773 Views

3 个回答

  • Voted
  1. Best Answer
    benjisail
    2010-02-24T10:12:56+08:002010-02-24T10:12:56+08:00

    所以回答我的问题:

    • 安装mailxyum install mailx
    • 安装发送邮件yum install sendmail
    • 开始发送邮件
    • 使用:而不是将MAILTO行放入 crontabcrontab -e[email protected]/etc/crontab
    • 11
  2. jcomeau_ictx
    2016-09-09T00:01:20+08:002016-09-09T00:01:20+08:00

    您可以通过安装 nullmailer 而不是 sendmail(或 exim4 或 postfix 等)来简化此操作。

    如果它不起作用,就像我的一样,并且您正在发送到诸如 gmail 之类的网络邮件服务:请确保您没有在其上放置任何过滤器。事实上,我对 cron 中的任何内容都有一个过滤器,以绕过收件箱。这就是为什么我没有从我的 cron 工作中看到任何东西。

    • 0
  3. hamx0r
    2017-08-17T10:03:04+08:002017-08-17T10:03:04+08:00

    我/var/log/maillog的显示crontab(with MAILTO=root) 正在尝试向两者发送电子邮件root和 root@my_fqdn(where my_fqdnis like server.something.com)。根据日志,发送到root成功和root@my_fqdn失败,但我发现没有消息在/var/mail/root. 这是相关的/var/log/maillog片段:

    Aug 16 17:49:02 ip-10-64-21-125 sendmail[22211]: v7GHn2Tr022211: from=root, size=742, class=0, nrcpts=1, msgid=<201708161749.v7GHn2Tr022211@my_fqdn>, relay=root@localhost
    Aug 16 17:49:02 ip-10-64-21-125 sendmail[22212]: v7GHn2Ws022212: from=<root@my_fqdn>, size=1061, class=0, nrcpts=1, msgid=<201708161749.v7GHn2Tr022211@my_fqdn>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
    Aug 16 17:49:02 ip-10-64-21-125 sendmail[22211]: v7GHn2Tr022211: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30742, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v7GHn2Ws022212 Message accepted for delivery)
    Aug 16 17:49:02 ip-10-64-21-125 sendmail[22214]: v7GHn2Ws022212: to=<root@my_fqdn>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=121061, relay=my_fqdn. [10.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by my_fqdn.
    

    但是,根据此提示,邮件现在显示在/var/mail/root. 该问题/etc/hosts需要添加一行,以便my_fqdn解决为域(注意末尾的点): 127.0.0.1 my_fqdn.

    注意:现在的工作方式是消息仍然无法正确接收,但会以某种方式反弹回来/var/mail/root(请注意stat=Local configuration error下面的/var/log/maillog代码片段)。

    Aug 16 17:50:04 ip-10-64-21-125 sendmail[22223]: v7GHo4ZJ022223: from=root, size=742, class=0, nrcpts=1, msgid=<201708161750.v7GHo4ZJ022223@my_fqdn>, relay=root@localhost
    Aug 16 17:50:04 ip-10-64-21-125 sendmail[22224]: v7GHo4MT022224: from=<root@my_fqdn>, size=1061, class=0, nrcpts=1, msgid=<201708161750.v7GHo4ZJ022223@my_fqdn>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
    Aug 16 17:50:04 ip-10-64-21-125 sendmail[22223]: v7GHo4ZJ022223: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30742, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v7GHo4MT022224 Message accepted for delivery)
    Aug 16 17:50:04 ip-10-64-21-125 sendmail[22226]: v7GHo4MT022224: SYSERR(root): my_fqdn. config error: mail loops back to me (MX problem?)
    Aug 16 17:50:04 ip-10-64-21-125 sendmail[22226]: v7GHo4MT022224: to=<root@my_fqdn>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=121061, relay=my_fqdn. [127.0.0.1], dsn=5.3.5, stat=Local configuration error
    Aug 16 17:50:04 ip-10-64-21-125 sendmail[22226]: v7GHo4MT022224: v7GHo4MT022226: DSN: Local configuration error
    Aug 16 17:50:04 ip-10-64-21-125 sendmail[22227]: v7GHo4Ml022227: localhost [127.0.0.1] did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA
    Aug 16 17:50:04 ip-10-64-21-125 sendmail[22226]: v7GHo4MT022226: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=62294, dsn=2.0.0, stat=Sent
    Aug 16 17:50:04 ip-10-64-21-125 sendmail[22226]: v7GHo4MT022226: to=<root@my_fqdn>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=62294, relay=my_fqdn., dsn=5.3.5, stat=Local configuration error
    Aug 16 17:50:04 ip-10-64-21-125 sendmail[22226]: v7GHo4MT022226: v7GHo4MU022226: return to sender: Local configuration error
    Aug 16 17:50:04 ip-10-64-21-125 sendmail[22226]: v7GHo4MU022226: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=33318, dsn=2.0.0, stat=Sent
    
    • 0

相关问题

  • 如何绕过 ISP 的限制性电子邮件政策?

  • SharePoint 传入电子邮件出现“未知别名”错误

  • 电子邮件帐户的角色名称与人名

  • 如何在笔记本电脑上使用 Tobit David?[关闭]

  • 随行人员通过 VPN 连接到 Exchange 2007

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve