Solved periodic via crontab will not follow MAILTO settings

1) Could someone explain why periodic daily/weekly/monthly commands set in /etc/crontab will ignore settings:

MAILTO="emailoutside@somedomain.com"
or MAILTO=""

Other tasks are good to follow what crontab(5) says, but periodic will not and always send emails to the owner (i.e. root from "who" column).

2) What will be a correct wait to keep periodic tasks run but not reporting any results, not even generate emails to queues?

>/dev/null 2>&1 will not work for them as well.

FreeBSD 11.2
 
  1. Because MAILTO and such are environment variables which can be used within the crontab specifications. But that doesn't automatically imply that the same environment will become available to every started script, such as the periodic scripts.
    1. It goes a bit deeper than that: /usr/sbin/periodic is a shell script and it seems plausible that it retains some of the environment variables. But that script then starts other scripts, making it less likely that the environment will remain intact (and it doesn't).
  2. See periodic(8):
Code:
     If the relevant variable (where <basedir> is the base directory in which
     the script resides) is set to "NO" in periodic.conf, periodic will mask
     the script output.  If the variable is not set to either "YES" or "NO",
     it will be given a default value as described in periodic.conf(5).

     All remaining script output is delivered based on the value of the
     <basedir>_output setting.
You can configure periodic using periodic.conf(5).
 
The difference of periodic scripts that they are not "every", but the part of the system and it doesn't look logical to me that they ignore these variables. Of course users' scripts can do what they want and follow or not follow these rules.

periodic.conf(5) doesn't say anything about configuration of "TO:", i.e. recipient of the periodic reports.
 
It's in the man - periodic.conf():

Code:
 <dir>_output
             (path or list) What to do with the output of the scripts executed
             from the directory dir.  If this variable is set to an absolute
             path name, output is logged to that file, otherwise it is taken
             as one or more space separated email addresses and mailed to
             those users.  If this variable is not set or is empty, output is
             sent to standard output.
 
Datapanic
Thanks.
How to understand these 3 variables for which dirs do not exist?
Code:
daily_status_security_output
daily_status_security_output
monthly_status_security_output
There are no dirs *_status_security_ in /etc/periodic/

Would it be enough to set just one "security_output=mailbox" instead of above 3?
 
Well, I don't know. You can try it, but I think you will need to handle each dir separately. The *_status_security_output entries work the same way as the *_ output entries. Also, don't change /etc/defaults/periodic.conf, instead, create /etc/periodic.conf.local and add your changes there.
 
You should set the e-mail address you desire to receive the periodic reports in /etc/mail/aliases:

Code:
root: EMAILADDRESS

because the periodic reports are sent to root.
 
Well, I don't know. You can try it, but I think you will need to handle each dir separately. The *_status_security_output entries work the same way as the *_ output entries. Also, don't change /etc/defaults/periodic.conf, instead, create /etc/periodic.conf.local and add your changes there.
Sure.
Manpage doesn’t mention security_output, but both the folder and log for rotation exist. So I just set all 4 *security_output for either the log for unattended boxes or emailing outside.
 
Back
Top