The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3e72ce4081f4a8d6b1d879dae201d569ce450261
commit 3e72ce4081f4a8d6b1d879dae201d569ce450261 Author: Lakshmikanth Ayyadevara <[email protected]> AuthorDate: 2025-10-02 16:08:09 +0000 Commit: Warner Losh <[email protected]> CommitDate: 2026-01-09 20:17:12 +0000 Cron: add CC and BCC option for crontab variables Signed-off-by: Lakshmikanth Ayyadevara <[email protected]> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1865 --- usr.sbin/cron/cron/do_command.c | 6 +++++- usr.sbin/cron/crontab/crontab.5 | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/usr.sbin/cron/cron/do_command.c b/usr.sbin/cron/cron/do_command.c index 43b3269d3087..58eed70c1be6 100644 --- a/usr.sbin/cron/cron/do_command.c +++ b/usr.sbin/cron/cron/do_command.c @@ -82,7 +82,7 @@ child_process(entry *e, user *u) { int stdin_pipe[2], stdout_pipe[2]; char *input_data; - const char *usernm, *mailto, *mailfrom; + const char *usernm, *mailto, *mailfrom, *mailcc, *mailbcc; PID_T jobpid, stdinjob, mailpid; FILE *mail; int bytes = 1; @@ -104,6 +104,8 @@ child_process(entry *e, user *u) */ usernm = env_get("LOGNAME", e->envp); mailto = env_get("MAILTO", e->envp); + mailcc = env_get("MAILCC", e->envp); + mailbcc = env_get("MAILBCC", e->envp); mailfrom = env_get("MAILFROM", e->envp); #ifdef PAM @@ -547,6 +549,8 @@ child_process(entry *e, user *u) fprintf(mail, "From: Cron Daemon <%s>\n", mailfrom); fprintf(mail, "To: %s\n", mailto); + fprintf(mail, "CC: %s\n", mailcc); + fprintf(mail, "BCC: %s\n", mailbcc); fprintf(mail, "Subject: Cron <%s@%s> %s\n", usernm, first_word(hostname, "."), e->cmd); diff --git a/usr.sbin/cron/crontab/crontab.5 b/usr.sbin/cron/crontab/crontab.5 index e4e6fae0b01b..5353e3de1b00 100644 --- a/usr.sbin/cron/crontab/crontab.5 +++ b/usr.sbin/cron/crontab/crontab.5 @@ -128,9 +128,19 @@ If is defined (and non-empty), mail is sent to the user so named. If +.Ev MAILCC +is defined (and non-empty), mail is carbon copied to the user(s) so named. +.Ev MAILBCC +is defined (and non-empty), +mail is blind carbon copied to the user(s) so named. +If .Ev MAILFROM is defined (and non-empty), its value will be used as the from address. .Ev MAILTO +, +.Ev MAILCC +and +.Ev MAILBCC may also be used to direct mail to multiple recipients by separating recipient users with a comma. If @@ -298,7 +308,9 @@ is started or the crontab entry is reloaded. SHELL=/bin/sh # mail any output to `paul', no matter whose crontab this is MAILTO=paul -# +# CC and BCC mail to `[email protected]' and '[email protected]' [email protected],[email protected] [email protected] # run five minutes after midnight, every day 5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1 # run at 2:15pm on the first of every month -- output mailed to paul
