rsync exit 0 before transfer complete

John Van Essen vanes002 at umn.edu
Tue Dec 20 09:06:19 GMT 2005


On Sat, 17 Dec 2005, Donna Livingstone <donna.livingstone at shaw.ca> wrote:
> 
> See below a snippet of the code I am using :
> 
>        if [ ! -s $file ]
>          then
>            # File does not exist or is non-zero
>            echo "file $file does not exit or is 0 size" >> $LOGFILE
>          fi
>        echo "About to rsync at `date`" >> rsync.out
>        if rsync -e rsh -av --timeout=60 `cat list` $SYS:/file_in >> rsync.out 2>&1
>        then
>          echo "completed rsync successfully at `date`" >> rsync.out
>          date >> filesent
>          cat list >> filesent
>          /bin/rm `cat list`
>        fi

The rsync output occuring after the 'completed' output means that rsync
is running detached in the background and the shell continued on after
starting it (prematurely removing the file that was being transferred
before rsync got to it).

To debug this - add a few lines:

       echo "About to rsync at `date`" >> rsync.out
       which rsync >> rsync.out  #DEBUG - find out which rsync is being run
       if rsync -e rsh -av --timeout=60 `cat list` $SYS:/file_in >> rsync.out 2>&1
       then
         ps auxwwf >> rsync.out  #DEBUG - show process tree to find rsync
         echo "completed rsync successfully at `date`" >> rsync.out


and then run your script to transfer a large file that will take, say,
at least 10 seconds in order to give the ps a chance to do its thang.
The 'f' option shows the process 'forest's (trees) so you can see if the
rsync process got detached from the script shell.  If it did... well -
you'll have to figure out why, 'cause I don't know.  :)

    John




More information about the rsync mailing list