LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   rsync non-existent path hangs (https://www.linuxquestions.org/questions/linux-software-2/rsync-non-existent-path-hangs-4175558788/)

IanVaughan 11-13-2015 10:02 AM

rsync non-existent path hangs
 
I have a list of syncs to perform, but sometimes they are not present on the remote server.
Is there a way to get it to gracefully skip/pass over these?

rsync -a server:/does/not/exist /here

Currently it hangs for ages and then bails out with `ssh: connect to host server port 22: Operation timed out`

lazydog 11-13-2015 10:45 AM

Are you running a script for this? If so maybe you should check for the the files or directories exist before the command is executed. I'm not a programmer but maybe something like this would work;

Code:

if [ -e server:/does/exist ]; then
        rsync -a server:/does/exist /here
fi


jmgibson1981 11-13-2015 12:37 PM

Code:

if ssh user@server "[[ -e /path/to/file]]" ; then
  do something
else
  do something else
fi

You will need ssh keys for this to work in a script else you will be prompted for password each time it cycles.

joe_2000 11-13-2015 05:51 PM

Quote:

Originally Posted by IanVaughan (Post 5449186)
Currently it hangs for ages and then bails out with `ssh: connect to host server port 22: Operation timed out`

This message looks to me like you can't even establish an ssh session. So any ssh command you'll run to check existance of remote directories will be slow to timeout just the same way.
Skipping over remote servers that are not available with a very small delay leads to the risk of having false positives... i.e. skipping over servers that actually are available and are just responding slowly. That's what timeouts are for!

That said, what you could do is reducing the timeout. If the syncs are on a fast link (local area network) you might want to reduce the connection timeout to a second or so:
Code:

ssh -o ConnectTimeout=1  <hostName>


All times are GMT -5. The time now is 09:20 PM.