How to Make cron send an error message email

Source: Internet
Author: User


How to make the cron send an error message know that if MAILTO is set, cron will send the task output to the specified mailbox. However, if you only want to receive an error alert email, that is, if the task is not sent during normal execution, but only when an error occurs, how can this problem be achieved? The method is simple. Specify the standard output of the task as/dev/null. MAILTO = mybox@gmail.com0 1 ** 1 script. sh>/dev/null principle: MAILTO sends all output of the task to the specified mailbox by default. Anyone familiar with linux/unix knows that the default output includes standard output and error output. Therefore, MAILTO directs both standard output and error output to the mail service. When we manually direct the standard output to/dev/null, the mail service will not be enabled normally, but the mail service will be started only when the error output contains content.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.