2

I have only one very simple shell script in /etc/hourly.cron. It just controls a Twitter bot- it runs a short python script that posts to Twitter using tweepy. It does not involve email or any sendmail commands.

I had this set up for nearly a year with no problems, but now it is failing with odd errors related to sendmail.

First, in /var/log/syslog, I was getting this:

Dec 30 10:17:01 sarah-ThinkPad-X220 CRON[29527]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Dec 30 10:17:02 sarah-ThinkPad-X220 cron[865]: Please install an MTA on this system if you want to use sendmail!
Dec 30 10:17:02 sarah-ThinkPad-X220 CRON[29526]: (root) MAIL (mailed 2136 bytes of output but got status 0x00ff from MTA#012)

I then installed postfix to try to debug this and got this:

Dec 30 15:17:01 sarah-ThinkPad-X220 CRON[4542]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Dec 30 15:17:03 sarah-ThinkPad-X220 cron[865]: sendmail: fatal: open /etc/postfix/main.cf: No such file or directory
Dec 30 15:17:03 sarah-ThinkPad-X220 postfix/sendmail[4546]: fatal: open /etc/postfix/main.cf: No such file or directory
Dec 30 15:17:03 sarah-ThinkPad-X220 CRON[4541]: (root) MAIL (mailed 250 bytes of output but got status 0x004b from MTA#012)

I am a cron novice and have no idea why an MTA would be needed at all. Any help would be appreciated.

s.py
  • 65
  • 3
  • 9

2 Answers2

4

By default, any output produced by things run by cron is sent by e-mail to the owner of the crontab. To disable this, either make sure your scripts do not produce any output, or redirect it to /dev/null in your crontab, or add MAILTO="" at the top of your crontab.

fkraiem
  • 12,555
  • 4
  • 35
  • 40
  • Thanks-- I added the MAILTO="". I'll see if it works in a few minutes, when my cron.hourly is scheduled to run :) – s.py Dec 30 '15 at 22:49
1

Just set in top of the cron file

MAILTO=""

And no mail will be send

muru
  • 197,895
  • 55
  • 485
  • 740