[Bug 1277493] [NEW] "MAILTO" Environment Variable is ignored when set in a file in /etc/cron.d/

annunaki2k2 russell at knighton.me.uk
Fri Feb 7 12:50:54 UTC 2014


Public bug reported:

I have a cron job definition file with the following:
----------------
# Runs every 5 minutes, logging into the proftpd database checking for expired accounts and disabling them.
MAILTO=sysadmin@[redacted].com,io@[redacted].com
*/5 *   * * *   root            /usr/local/sbin/proftpd-expire.sh
----------------

Any output from the script ought to be emailed to both the sysadmin & io group addresses, but instead output is always sent to 'root@[local FQDN]', presumably becasue the cron job is being executed as root. For some reason, the MAILTO environment variable is being ignored, as can be confirmed when looking at the email (sent to root) for all the "X-cron-env" headers:
----------------
X-cron-env: <SHELL=/bin/sh>
X-cron-env: <HOME=/root>
X-cron-env: <PATH=/usr/bin:/bin>
X-cron-env: <LOGNAME=root>
----------------
There is clearly no MAILTO header in this email, and obviously the main proof is that this still only went to root at fqdn.

All documentation appears to say that the combination of MAILTO and a
file in /etc/cron.d/ should work.

** Affects: cron (Ubuntu)
     Importance: Undecided
         Status: New

** Attachment added: "Output of "apport-cli -f -p cron""
   https://bugs.launchpad.net/bugs/1277493/+attachment/3972394/+files/mailto_ignored_by_cron_bug.apport

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to cron in Ubuntu.
https://bugs.launchpad.net/bugs/1277493

Title:
  "MAILTO" Environment Variable is ignored when set in a file in
  /etc/cron.d/

Status in “cron” package in Ubuntu:
  New

Bug description:
  I have a cron job definition file with the following:
  ----------------
  # Runs every 5 minutes, logging into the proftpd database checking for expired accounts and disabling them.
  MAILTO=sysadmin@[redacted].com,io@[redacted].com
  */5 *   * * *   root            /usr/local/sbin/proftpd-expire.sh
  ----------------

  Any output from the script ought to be emailed to both the sysadmin & io group addresses, but instead output is always sent to 'root@[local FQDN]', presumably becasue the cron job is being executed as root. For some reason, the MAILTO environment variable is being ignored, as can be confirmed when looking at the email (sent to root) for all the "X-cron-env" headers:
  ----------------
  X-cron-env: <SHELL=/bin/sh>
  X-cron-env: <HOME=/root>
  X-cron-env: <PATH=/usr/bin:/bin>
  X-cron-env: <LOGNAME=root>
  ----------------
  There is clearly no MAILTO header in this email, and obviously the main proof is that this still only went to root at fqdn.

  All documentation appears to say that the combination of MAILTO and a
  file in /etc/cron.d/ should work.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1277493/+subscriptions



More information about the foundations-bugs mailing list