Published on

rsync script

183 words1 min read

# Find running rsync processes that aren't the one we spawn (grep) with this command
RUNNING="$(ps -ef | grep rsync | grep --invert-match 'grep')"

# Only spawn more rsync jobs if there aren't some already running
if [[ -z "$RUNNING" ]]; then
    echo "Running rsync commands"

	rsync -aqz --remove-source-files --no-o --no-g --no-perms /source/files /destination > /dev/null 2>&1 &
        echo "Not running rsync commands, there is one already running"