Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to sync Server1 and Server2's logs to LogServer.

For Server1:

rsync -avz -e 'ssh -p 2188' user@server1:/usr/local/servers/logs/* /usr/local/logs/

This one works, but for Server2:

rsync -avz -e 'ssh -p 2188' user@server2:/usr/local/servers/logs/* /usr/local/logs/

It fails:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: no such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: no such file or directory
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: no such file or directory
rsync: getcwd(): No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at util.c(992) [sender=3.0.6]
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [receiver=3.0.6]

Both Server1 and Server2 is hosted on Amazon with the same version of rsync.

I am quite sure that every directory in the command is exists. How can I solve this problem?

UPDATE: I have tried ssh -p 2188 user@server2 pwd, and it doesn't work:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: no such file or directory

job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: no such file or directory

Screenshot

enter image description here

share|improve this question
1  
What user are you using for rsync? I've seen that error when the current user doesn't have permissions to access the directory structure. – Sobrique Apr 28 '14 at 11:09
1  
Or when the user's home directory doesn't exist on the server. – Jenny D Apr 28 '14 at 11:10
    
Current user have read permission to those logs and home directory is exist. – MrROY Apr 28 '14 at 14:42
    
Manually SSH into server2 as user. Does that work without any errors? If so, does ls -R /usr/local/servers work without any errors? – sciurus Apr 28 '14 at 17:41
1  
Yes, it works without any errors ! – MrROY Apr 29 '14 at 4:16

I had the exact same issue, and my solution was something I had never thought of. In my case rsync worked fine for all the time until it stopped during some tests after changes to one of my scripts. The culprit was that my currently logged in UNIX user was in a non-existent folder that was already deleted by a script.

The getcwd(): No such file or directory (2) error message was related to $PWD, not the source, and not the destination.

Just change the folder to an existing one (e. g. cd ~) and re-run the script. Don’t forget to alter rsync paths if they aren’t already absolute.

share|improve this answer
    
Thanks man, it saved me. – Mohammad Apr 18 at 15:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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