e-mail from cron

David King dking at ketralnis.com
Wed Aug 23 17:54:58 UTC 2006


>> 30      5       1       *       *       root    periodic monthly 2>&1
>> | sendmail service at jellico.com
>> but all I get is a blank email sent to service at jellico.com
> [...]
> also.. using 2>&1 doesn't seem appropriate, afaik you would use  
> that in
> crontab if you don't want to get emails via cron

You would use "2>&1" in conjunction with ">/dev/null" if you didn't  
want to get emails from cron, sure. But if you don't redirect stderr,  
then stderr doesn't end up in the mail.

That is, if "periodic monthly" outputs stdout and stderr, and you  
only redirect (with "|") stdout, then you don't get the stderr.  
"2>&1" says, "send output from file-descriptor 2 (stderr) to file- 
descriptor 1 (stdout)". That way the redirection with the pipe  
contains both stdout and stderr.

As far as redirecting the periodic output to a different user, set  
"daily_output" in /etc/periodic.conf. See /etc/defaults/periodic.conf  
for an example. You'd of course have to do the same for weekly and  
monthly.


More information about the freebsd-questions mailing list