Linux / UNIX: Change Crontab Email Settings ( MAILTO )

Q. I'd like to send email to user@example.com instead of default root user. How do I change email settings under crontab file?

A. A crontab file contains instructions to the cron daemon.

An active line in a crontab will be either an environment setting or a cron command. An environment setting is of the form:

 name = value

where the spaces around the equal-sign (=) are optional, and any subsequent non-leading spaces in value will be part of the value assigned to name. The value string may be placed in quotes (single or double, but matching) to preserve leading or trailing blanks. The value string is not parsed for environmental substitutions, thus lines like

PATH = $HOME/bin:$PATH

will not work as you might expect.

MAILTO Variable

In addition to LOGNAME, HOME, and SHELL, cron will look at MAILTO if it has any reason to send mail as a result of running commands in "this" crontab. If MAILTO is defined (and non-empty), mail is sent to the user so named. First open your crontab file:
# vi /etc/crontab
OR
$ crontab -e
To send email to vivek@nixcraft.in, enter:
MAILTO=vivek@nixcraft.in

If MAILTO is defined but empty (MAILTO=""), no mail will be sent.
MAILTO=""

Otherwise mail is sent to the owner of the crontab.


转载自:http://www.cyberciti.biz/faq/linux-unix-crontab-change-mailto-settings/




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值