简体   繁体   中英

How to ignore rsync warning about vanished files?

I get a lot of mails from cronjobs with rsync. And I've tried to ignore it with wrapper script like this:

#!/bin/bash
/usr/bin/rsync "$@"
e=$?
if test $e = 24; then
    exit 0
fi
exit $e

And saved it like a /usr/bin/rsync-no24

After that, I changed my script for cronjob:

#!/bin/bash

SOURCE_BASE="/var/www/"
TARGETS="server30"
TARGET_DIR="/var/www/"
RSYNC_BIN="/usr/bin/rsync-no24"
RSYNC_OPTIONS="-aqqq"

/usr/bin/find ${SOURCE_BASE}/typo3temp ! -user www-data -exec chown -R www-data:www-data {} \;

#for SOURCE_DIR in fileadmin uploads typo3temp
#do
        for TARGET_HOST in ${TARGETS}
        do
                ${RSYNC_BIN} ${RSYNC_OPTIONS} ${SOURCE_BASE}/${SOURCE_DIR} ${TARGET_HOST}:${TARGET_DIR}/
        done
#done

But anyway I still get mails from cron such as

file has vanished: "/var/www/stage2/typo3temp/tx_ncstaticfilecache/OnlineBackup/index33.html.5"

How to ignore messages like this? Probably something wrong with wrapper script?

Thanks a lot.

Replace your /usr/bin/rsync-no24 with this:

#!/bin/bash
(rsync "$@"; if [ $? == 24 ]; then exit 0; else exit $?; fi) 2>&1 | grep -v 'vanished'

source

(on a side note, I don't think there's a difference between RSYNC_OPTIONS="-aqqq" and RSYNC_OPTIONS="-aq"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM