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 very simple, specifying... information
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.
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.