Do cron job notifications only go to root's email?

Constantin

Vampire Pig
Joined
May 19, 2017
Messages
1,829
A while back, I decided to change the mailto: address for email (see System -> Add Alert Service in the GUI) from one account to another. The change is easy enough, except my CRON task notifications didn't migrate also. They appear to be 100% bound to the email associated with root vs. being part of the Alert Settings universe (see /etc/mail/aliases).

Is this by design? If so, why? Shouldn't one should be able to specify a mailto address with each CRON task, if such a notification is desired? Apologies for me likely being dense but it seems a bit incongruous that alert services goes on for three pages yet CRON isn't part of that mix.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
They go to the user running the cron job.

You can override that in the crontab with a "MAILTO" entry, although I don't know if and how the TrueNAS UI supports that. How about you experiment a little and report back? :wink:

 

Constantin

Vampire Pig
Joined
May 19, 2017
Messages
1,829
If you stick to the UI (which seems to be the default way to do things) then cron task results are sent to the mail account associated with root.

I don’t know if one could change that behavior substantially without making changes to the UI and the middleware. From a maintenance viewpoint, it could be interesting to allow cron task mailto’s to be specified (and if left empty default to root’s mailto). That way specific groups or personnel could be notified if a cron task does not execute as expected.

no doubt, experienced sysadmins likely set up aliases on their mail server to distribute stuff based on the from, the subject header, etc. to one or more staff as needed, and perhaps a single node where this is specified actually works better in practice than a more machine-by-machine approach.

However, it would be great if the GUI cron task page would state that all cron task results will be mailed to root’s mailto address. Just in case folk start wondering why a cron hiccup didn’t trigger a warning.

To me, cron notifications really belong in the alerts page, along side other important data like whether a SSL certification just expired and so on. It’s yet another important machine status notification.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
If you stick to the UI (which seems to be the default way to do things) then cron task results are sent to the mail account associated with root.
You can run the cron jobs as a configurable user from the UI. Doesn't that respect the user's email address if configured? That would be a POLA violation in my book.

I could not find the cronjobs I configured on my system. Any idea where they are stored? It's not /var/cron/tabs ...
 
Joined
Jan 4, 2014
Messages
1,644

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Maybe start here
I do not intend to manually add crontab entries. I just tried to find out where TN stores the ones defined in the UI. To check if it actively sets MAILTO to "root". /var/cron/tabs is empty and /etc/crontab does not contain my jobs, either. Although they do run.
 
Joined
Jan 4, 2014
Messages
1,644
I just tried to find out where TN stores the ones defined in the UI.
This has something to do with it cat /etc/cron.d/middlewared. I recognise the times for cron jobs I've defined in the UI. Still haven't figured out where the commands are stored for each job.
 
Top