I want to start multiple rsync sesssions via screen in detached mode? Is it possible? I need to run rsync script for each file in folder.

screen -t -d sshpass -p 123456 rsync5 rsync -avzP /home/vagrant/test_folder/ user@

But it returns Must be connected to a terminal.

  • tmux is easier to automate – chicks Oct 12 '15 at 17:25

So if you need to start multiple rsync sessions try next solution:

# paths for rsync in "/folder/folder/folder" format
export SRCDIR="$1"
export DESTDIR="$2"
# Number of threads for xargs
export THREADS="20"
cd $SRCDIR; find . ! -type d -print0 | xargs -0 -n1 -P$THREADS -I% rsync  -az %$DESTDIR/%

If you use key auth you may use ssh-agent for automate entering a passphrase for your key.

ssh-agent bash
ssh-add /home/username/.ssh/id_rsa
Enter passphrase for /home/username/.ssh/id_rsa: 
Identity added: /home/username/.ssh/id_rsa (/home/username/.ssh/id_rsa)


  1. https://wiki.ncsa.illinois.edu/display/~wglick/Parallel+Rsync
  2. https://askubuntu.com/questions/362280/enter-ssh-passphrase-once

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.