[PLUG] Make cron send an e-mail upon completion
John Jason Jordan
johnxj at gmx.com
Mon Jan 27 19:52:34 UTC 2020
On Mon, 27 Jan 2020 11:08:19 -0800 (PST)
Rich Shepard <rshepard at appl-ecosys.com> dijo:
>Try putting these three lines in your cron script:
>
>MAILTO=myusername at gmx.com
>TS=`date`
>...
>echo "$TS - Home Backup Completed" | mail $MAILTO
Thanks, I think I'm getting closer now. Previously, while working on
getting the rsync command to do what I wanted, I had been just running
the command as root in the terminal window. (I use it as root with the
-a option to preserve ownerships, lest the backup end up owned by root.)
Last night I put it into a root cron job to run at 3:15am, but this
morning I had no idea if it had succeeded or not. So I went back to the
command line to add the mail option. In all this time I had not
bothered with a script because the command was just one line.
So just now I made a script so I could have more than one line, and
having done so I ran it from the terminal. The script ended with:
mail: cannot send message: Process exited with a non-zero status
I suspect that this is actually an rsync error, although the rsync
command still has -v option so I could watch as it progressed, and I
didn't see any error messages. I remember reading in the rsync man page
about exit codes, but all I remember is that 0 means 'no errors,' or
such. Maybe I need the mail to tell me what happened. And make rsync
send the mail even if the exit status is non-zero.
More information about the PLUG
mailing list