SLUG Mailing List Archives
Re: [SLUG] Mailing Script Results
- To: SLUG List <slug@xxxxxxxxxxx>
- Subject: Re: [SLUG] Mailing Script Results
- From: James Gray <james@xxxxxxxxxxxxxxxx>
- Date: Wed, 30 Aug 2006 12:23:16 +1000
On 30/08/2006, at 11:17 AM, Kevin Fitzgerald wrote:
Pretty easy one I imagine. I am doing an rsync between 2 servers
like to get the results emailed to me once the script completes. I
adding > mailx -s "subject" email@xxxxxxxxx to the end of my script
So what do I do?
Box is Fedora Core 4
Sendmail service is running
Here's the way I normally handle this sort of thing:
Create script that you will call from cron with the following script
MAILSUB="Results from myscript"
Then set the umask for the script so the temp file is secure before
you write to it, and create the temp file:
rm -rf $RESULT >/dev/null 2>&1
You should check the result of the "rm" and possible the "touch" to
make sure nothing bad happend.
Then simply run your rsync, output the results to $RESULT and send
rysnc [with all the opts] > $RESULT
mail -s "$RESULT" $MAILTO < $RESULT
Voila! You probably want to tidy up the temp file when you're done
too, but I'll leave that as an exercise for you. If you need more
than one person to receive the results, I usually create an alias in
sendmail (/etc/aliases) with the necessary recipients then set the
$MAILTO to match the alias.