Hacker News new | ask | show | jobs
by ecnahc515 409 days ago
Cronjobs often run as root. If the host has is configured to send emails when a cronjob is completed it will default to sending it to user@domain where the user is the user the cronjob runs as, and the domain is what was configured in the cron configuration.
1 comments

Minor nitpicky correction: cron only sends an email if there's any stdout of the job.

This is an important distinction because if you have configured mail forwarding, your cron jobs should be configured to output only on error.. then any emails are actionable.

Moreutils has a great command `chronic` which is a wrapper command like `time` or `sudo`, ie. you just run `chronic <command>`. It'll supress stdout and stderr until the command exits at which point it will print only if the exit code was non-zero.
I copied the same idea in my static collection of sysadmin utilities:

https://github.com/skx/sysbox/