Re: [PLUG] Make cron send an e-mail upon completion
On Mon, 27 Jan 2020, John Jason Jordan wrote: Also, I have mail and mailutils installed, but not much more. I want to keep this as simple as possible. I have used Claws-Mail for years and it has never failed me. I have plenty of software installed on this computer; I don't need or want additional mail clients. John, Linux mail systems have three main components: the MUA (Mail User Agent) which is used to read and write messages; the SMTP (Simple Mail Transport Protocol) used to send and receive mail messages; and the MDA (Mail Delivery Agent) which examines incoming messages and forwards them to the proper receiver. Claws-mail is a MUA, similar to Thunderbird, Eudora, mutt, and alpine. To send mail you need an MTA; sendmail is the default while postfix and exim are widely used replacements. You have the e-mail equivalent of a telephone without a telco/wireless account. If you want to mail messages to yourself to need to add the transport layer. HTH, Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Make cron send an e-mail upon completion
You're not telling "mail" to mail anything. Since you're no longer piping you need to redirect something to STDIN. mail -s "my subject" $recipient wrote: > On Mon, 27 Jan 2020 13:41:05 -0800 > John Jason Jordan dijo: > > >>> mail: cannot send message: Process exited with a non-zero status > > Just to add something that I discovered: That error message is from > mail, not from rsync. I get the same error message when I just try to > send an e-mail from the command line directly without even running the > rsync script. > > Also, I have mail and mailutils installed, but not much more. I want to > keep this as simple as possible. > > I have used Claws-Mail for years and it has never failed me. I have > plenty of software installed on this computer; I don't need or want > additional mail clients. If I have to set up a complete mail server > just to get a bash script to send me an e-mail, then better I should > just give up the idea and find an easier way to get the rsync cron job > script to notify me that it worked or didn't work. > ___ > PLUG mailing list > PLUG@pdxlinux.org > http://lists.pdxlinux.org/mailman/listinfo/plug > ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Make cron send an e-mail upon completion
On Mon, 27 Jan 2020 13:41:05 -0800 John Jason Jordan dijo: >>> mail: cannot send message: Process exited with a non-zero status Just to add something that I discovered: That error message is from mail, not from rsync. I get the same error message when I just try to send an e-mail from the command line directly without even running the rsync script. Also, I have mail and mailutils installed, but not much more. I want to keep this as simple as possible. I have used Claws-Mail for years and it has never failed me. I have plenty of software installed on this computer; I don't need or want additional mail clients. If I have to set up a complete mail server just to get a bash script to send me an e-mail, then better I should just give up the idea and find an easier way to get the rsync cron job script to notify me that it worked or didn't work. ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Make cron send an e-mail upon completion
On Mon, 27 Jan 2020 13:06:17 -0800 (PST) Rich Shepard dijo: >On Mon, 27 Jan 2020, John Jason Jordan wrote: > >> 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 >Did you look in /var/log/ to see if that error shows up in a file? Yes, found no files about rsync or mail. Looked in syslog, but no messages about rsync or mail, either. One thing that may be hanging up the mail is that if I just do 'mail some...@somedomain.com' from the command line it immediately pops up a line expecting me to add a Cc. I scoured the mail and mailutils man pages and found no way to tell it to shut up and just send the mail. I also don't know what to add for the Cc line; it hangs the mail until I give it what it wants, so I have to kill mail. Here is the current incarnation of my script: #!/bin/bash MAILTO=some...@gmx.com TS=`date` rsync -av --delete /home/jjj/ /media/jjj/Data/JJJ mail -s "$TS Home Backup Done Exit Status $?" $MAILTO This now ends with the Cc line, and hangs waiting for input. And if I just do 'echo $TS Home Backup Done Exit Status $?' it displays the information that I want, so the -s line above should work, if I can just get it to send the mail. Of course, I don't know what would happen to the e-mail if the exit status is other than 0, assuming I can finally get it to work. ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Make cron send an e-mail upon completion
On Mon, Jan 27, 2020 at 12:55 PM John Jason Jordan wrote: > > I've read online all kinds of advice, but none succeed. The closest > I've gotten is: > > # | mail -s "Home is backed up" myusern...@gmx.com > > Which gives the error message 'mail: cannot send message: Broken pipe.' > > I have lots of plumbing tools and experience using them for fixing > houses, but this message is beyond me. How do I fix a broken Linux pipe? I would guess that you need to configure your system's email postfix/sendmail or whatever your distribution uses so that it can send mail. This usually means configuring some type of smarthost, an SMTP server at gmail or ... which you have an account on that can forward your mail to its destination. Configuring a smarthost bypasses the need to setup a full fledged SMTP server that can send/receive mail and all the complications that involves. https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-16-04 Bill > ___ > PLUG mailing list > PLUG@pdxlinux.org > http://lists.pdxlinux.org/mailman/listinfo/plug ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Make cron send an e-mail upon completion
On Mon, 27 Jan 2020, John Jason Jordan wrote: 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 John, Did you look in /var/log/ to see if that error shows up in a file? Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Make cron send an e-mail upon completion
On Mon, 27 Jan 2020 11:08:19 -0800 (PST) Rich Shepard dijo: >Try putting these three lines in your cron script: > >MAILTO=myusern...@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. ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Make cron send an e-mail upon completion
From the rsync man page: --outbuf=MODE This sets the output buffering mode. The mode can be None (aka Unbuffered), Line, or Block (aka Full). You may specify as little as a single letter for the mode, and use upper or lower case. The main use of this option is to change Full buffering to Line buffering when rsync’s output is going to a file or pipe. You probably want to mess with this. On Mon, Jan 27, 2020 at 10:55 AM John Jason Jordan wrote: > I've read online all kinds of advice, but none succeed. The closest > I've gotten is: > > # | mail -s "Home is backed up" myusern...@gmx.com > > Which gives the error message 'mail: cannot send message: Broken pipe.' > > I have lots of plumbing tools and experience using them for fixing > houses, but this message is beyond me. How do I fix a broken Linux pipe? > ___ > PLUG mailing list > PLUG@pdxlinux.org > http://lists.pdxlinux.org/mailman/listinfo/plug > ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Make cron send an e-mail upon completion
On Mon, 27 Jan 2020, John Jason Jordan wrote: I've read online all kinds of advice, but none succeed. The closest I've gotten is: # | mail -s "Home is backed up" myusern...@gmx.com Which gives the error message 'mail: cannot send message: Broken pipe.' John, Try putting these three lines in your cron script: MAILTO=myusern...@gmx.com TS=`date` ... echo "$TS - Home Backup Completed" | mail $MAILTO HTH, Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] Make cron send an e-mail upon completion
First thing to check is that the command syntax runs in the foreground. Also remember that jobs run from cron don't get the same environment as you have when logged in. There might be a path issue somewhere. Cathy -- Cathy L. Smith IT Engineer Pacific Northwest National Laboratory Operated by Battelle for the U.S. Department of Energy Phone: 509.375.2687 Fax: 509.375.4399 Email: cathy.sm...@pnnl.gov -Original Message- From: plug-boun...@pdxlinux.org On Behalf Of John Jason Jordan Sent: Monday, January 27, 2020 10:56 AM To: PLUG Subject: [PLUG] Make cron send an e-mail upon completion I've read online all kinds of advice, but none succeed. The closest I've gotten is: # | mail -s "Home is backed up" myusern...@gmx.com Which gives the error message 'mail: cannot send message: Broken pipe.' I have lots of plumbing tools and experience using them for fixing houses, but this message is beyond me. How do I fix a broken Linux pipe? ___ PLUG mailing list PLUG@pdxlinux.org https://protect2.fireeye.com/v1/url?k=7a60856f-26d5bba0-7a60af7a-0cc47adc5e60-ea9bccb9b4c0caae&q=1&e=df460f8a-e5b9-4e32-a360-cc51ea54d95b&u=http%3A%2F%2Flists.pdxlinux.org%2Fmailman%2Flistinfo%2Fplug ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug