Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I have this problem, I only want to be emailed upon failure. However, the crontab of the account is shared by several different jobs run by different people, and I don't have control over that. Perhaps I could set the email in the crontab line?

* * * * * MAILTO=me@example.com blahscript.sh



You can set MAILTO by itself between the job lines in the crontab; e.g.:

    MAILTO=user1@example.com
    * */10 * * * script1
    5 * * * * script2
    MAILTO=user2@example.com
    * * * * * script3
Any output from script1 and 2 will be sent to user1 and any from script3 to user2.


Not all cron daemons. Vixie cron can do this, but Dillon's cron, which is a lightweight cron daemon with extra features, can't.


Thanks for the clarification.


    blahscript.sh | mail -s "Subject" me@example.com


That always sends an email, even if the body is empty.


mail -E




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: