I have a bash script set up on computer A (Mac OS X) set to run every five minutes via a cronjob. This script checks for new files on remote computer B (Gentoo Linux) then rsyncs any new files to computer A. Sometimes this sync (download) maxes out my connection at 3 MB/s, however sometimes, maybe 10% of the time, it will download at the extremely low rate of 10-50 KB/s. I'm 100% certain this isn't because my Internet connection is dying out/dipping so what could be at fault?The weird thing is that the rsync jobs that run slow, run slow the ~entire~ time. That is if it is rsyncing a 1 GB file it will sync/download at its extremely slow speed (10-50 KB/s) the entire life of the job until the 1 GB is fully downloaded. This leads me to believe it is not related to CPU load, or networking, but with either the script or something else.My script is below.# !/bin/sh# Check if rsync has been timestampped and exit if it hasecho Checking for local timestamp... >> /Users/localuser/log/rsync.logif [ -e /Users/localuser/scripts/.timestamp ]then        echo Local timestamp already exists, exiting... >> /Users/localuser/log/rsync.log        exitfi# Timestamp rsyncecho Local timestamp not found, continuing... >> /Users/localuser/log/rsync.logtouch /Users/localuser/scripts/.timestamp# Timestamp remote computer Becho Timestampping remote computer B >> /Users/localuser/log/rsync.logssh remoteuser@remotecomputerb touch /home/remoteuser/finished/.timestamp# Run rsyncecho Starting rsync at $(date) >> /Users/localuser/log/rsync.logrsync -avzPL -e ssh remoteuser@remotecomputerb:/home/remoteuser/finished /share --log-file /Users/localuser/log/rsync.log# Change permissionsecho Changing permissions >> /Users/localuser/log/rsync.logchmod -Rf 775 /share/usr/sbin/chown -Rf localuser:staff /share# Delete sym links that are older than the remote computer B timestampecho Deleting sym links on remote computer B >> /Users/localuser/log/rsync.logssh remoteuser@remotecomputerb find /home/remoteuser/finished \! -newer /home/remoteuser/finished/.timestamp -type -l -delete# Delete the rsync script timestampecho rsync finished at $(date) >> /Users/localuser/log/rsync.logrm /Users/localuser/scripts/.timestampexit 0
rsync over SSH sometimes very slow--other times maxes out bandwidth
bash;ssh;osx;rsync;backup
That could be basically anything from link congestion to high CPU usage on the remote computer. In between, all the network devices can also screw up. Especially since you are bombing the ssh port. But buffering problems in the network devices can also be the culprits. One thing though: next time, double check that rsync is not running twice. Yes, you created workarounds in the script to avoid that, but one never knows... maybe the folder is read-only, maybe the filesystem behaves strangely...So, you understand it, we don't have enough information to answer correctly.However, I would recommend you to stop using rsync for this use case. This is inefficient as well as error prone. Since what you want is folder constant sync, have a look at syncthings. It should work better, without lag with the same amount of openness and security. (rsync is great for one-shots and for periodic backups, not for constantly syncing folders)