Hi, On Wed, 30 Dec 2009, Sébastien Arpin wrote:
I have a bash script for rsync that should tranfer all my filer from one drive to the other.I would like to know how I can make the script sending me an email after the script is run and be able to know if it was a success or not and also if possible to include the log file.
I do it this way: rsync ${ALLOPTS} ${SRC} ${DST} >>${PROT} 2>&1 RC=$? DAT2="`date +%y%m%d.%H%M`" if test "${RC}" = "0" -o "${RC}" = "23"; then grep "^Total file size: " ${PROT} | \ ( read a b c d e echo "${DAT2} ${NAM} size: $d bytes." >>${DST}/.gwdg-mirror ) else touch ${DST}/.gwdg-mirror fi echo "==== end ======== RC=${RC} ============ ${DAT1} ${DAT2}" >>${PROT} MAILIT=yes if [ "${RC}" = "0" ]; then NUMFIL=`grep "^Number of files transferred:" ${PROT} | \ (while read n o f t X; do echo -n ${X}; done)` if [ "${NUMFIL}" = "0" ]; then MAILIT=no fi fi if [ "${MAILIT}" = "yes" ]; then V1="is uptodate" V2="is a hard link" V3="^backed up " V4="^deleting " grep -v "${V1}\|${V2}\|${V3}\|${V4}" ${PROT} | \ mail -s"${SUBJ} (RC=${RC})" ${MAILTO} #else # mail -s"${SUBJ} (RC=${RC}) __nomail__" ${MAILTO} <${PROT} fi Viele Gruesse Eberhard Moenkeberg (emoe...@gwdg.de, e...@kki.org) -- Eberhard Moenkeberg Arbeitsgruppe IT-Infrastruktur E-Mail: emoe...@gwdg.de Tel.: +49 (0)551 201-1551 ------------------------------------------------------------------------- Gesellschaft fuer wissenschaftliche Datenverarbeitung mbH Goettingen (GWDG) Am Fassberg 11, 37077 Goettingen URL: http://www.gwdg.de E-Mail: g...@gwdg.de Tel.: +49 (0)551 201-1510 Fax: +49 (0)551 201-2150 Geschaeftsfuehrer: Prof. Dr. Bernhard Neumair Aufsichtsratsvorsitzender: Dipl.-Kfm. Markus Hoppe Sitz der Gesellschaft: Goettingen Registergericht: Goettingen Handelsregister-Nr. B 598 -------------------------------------------------------------------------
-- Please use reply-all for most replies to avoid omitting the mailing list. To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html