1

My goal is to send everything that gets output from the cron daemon (no matter which crontab) to an external email address with the correct TO email header.

I set MAILTO in /etc/default/cron to MAILTO=root and set /etc/postfix/virtual to root [email protected]. This setup works, output from each crontab is delivered to [email protected], but the annoying thing is that, the TO email header does not change, it's still [email protected] - the only change is that an additional Delivered-To: [email protected] is added. Even though the message is received by the external email address I don't like the fact that I have a wrong TO - I want to have a clean and tidy setup. That means to me that I'm doing something wrong here.

If I set MAILTO in each crontab separately the correct TO header is set - but this is to much work, I have to alter each crontab, that's why I want to have a general solution.

How do I send everything that gets output from the cron daemon to an external email address with the correct TO email header?

1 Answer 1

1

Typically I create a file in the root user's $HOME named .forward. In this file place the e-mail address you want all your root user mail to goto. It will catch more than just your cron output however. Any system mail going to the root user will be forwarded.

For many, many moons, this is just something I typically do on systems I manage. Drop my work e-mail into a .forward file in root's $HOME. Yes, I need a filter that puts all this mail into a folder so it won't clobber my Inbox, but it's a great way to keep track of a larger fleet of systems without logging into each machine daily to see how it's doing. Logwatch, cron, errors, other script output. All good stuff to have mailed to yourself @work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .