Results 1 to 5 of 5

Thread: crontab MAILTO="" is not working

  1. #1
    Join Date
    Jul 2015
    Beans
    7

    crontab MAILTO="" is not working

    Before anyone gets too incensed, please know that I have googled this and have yet to find a viable or applicable solution. So...
    I am running Ubuntu Server 12.04, and run tripwire every morning. I have a tripwire report emailed to me, but a copy of that report is also emailed to the root account on that server, and I cannot stop these emails.

    Running
    Code:
    sudo crontab -e
    my crontab looks like this:

    Code:
    MAILTO=""
    0 5 * * * /usr/sbin/tripwire --check | mail -s "Daily Tripwire Report" me@mydomain.com
    Am I setting the MAILTO variable incorrectly?
    Any thoughts on stopping the local email to root but still receiving the external email?

    Thx

  2. #2
    Join Date
    Aug 2009
    Location
    Makati City, Philippines
    Beans
    2,269
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: crontab MAILTO="" is not working

    From here: http://unix.stackexchange.com/questi...ob-to-dev-null

    try redirecting all output to /dev/null
    0 5 * * * /usr/sbin/tripwire --check | mail -s "Daily Tripwire Report" me@mydomain.com > /dev/null 2>&1

  3. #3
    Join Date
    Jul 2015
    Beans
    7

    Re: crontab MAILTO="" is not working

    Thanks, I'll give it shot. I actually thought about this, but wasn't sure if /dev/null would squash the email I did want. Will let you know...

  4. #4
    Join Date
    Aug 2009
    Location
    Makati City, Philippines
    Beans
    2,269
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: crontab MAILTO="" is not working

    Quote Originally Posted by jay98 View Post
    Thanks, I'll give it shot. I actually thought about this, but wasn't sure if /dev/null would squash the email I did want. Will let you know...
    If the /dev/null squashes even the content of the email, then move your cron commands to a script file, then trigger the script using cron. Something like:
    0 5 * * * /bin/bash /my/tripwire/script.sh > /dev/null 2>&1


    Then the contents of the script.sh is:
    Code:
     #!/bin/bash
    /usr/sbin/tripwire --check | mail -s "Daily Tripwire Report" me@mydomain.com

  5. #5
    Join Date
    Jul 2015
    Beans
    7

    Re: crontab MAILTO="" is not working

    This did not work
    I actually got both emails; the email to me@mydomain.com, and the email to root on that box.
    MAILTO="" and redirecting output to /dev/null 2>&1 are ignored completely.

    I am editing cron with
    Code:
    sudo crontab -e
    The same way I added the cron job itself...

    Any thoughts?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •