mirror of
https://git.freebsd.org/src.git
synced 2026-01-11 19:57:22 +00:00
Cron: add CC and BCC option for crontab variables
Signed-off-by: Lakshmikanth Ayyadevara <lakshmikanth.a.ayyadevara@oracle.com> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1865
This commit is contained in:
parent
5395471516
commit
3e72ce4081
2 changed files with 18 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 `lakshmikanth@example.com' and 'paul@example.com'
|
||||
MAILCC=lakshmikanth@example.com,paul@example.com
|
||||
MAILBCC=peter@example.com
|
||||
# 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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue