rsync: getcwd(): 没有那个文件或目录 (2)

Woo*_*aaa 12 linux ssh shell rsync

我想将Server1Server2的日志同步到LogServer.

对于Server1

rsync -avz -e 'ssh -p 2188' user@server1:/usr/local/servers/logs/* /usr/local/logs/
Run Code Online (Sandbox Code Playgroud)

这个有效,但对于Server2

rsync -avz -e 'ssh -p 2188' user@server2:/usr/local/servers/logs/* /usr/local/logs/
Run Code Online (Sandbox Code Playgroud)

它失败:

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]
Run Code Online (Sandbox Code Playgroud)

双方Server1Server2托管在亚马逊具有相同版本的rsync

我很确定命令中的每个目录都存在。我怎么解决这个问题?

更新:我试过了ssh -p 2188 user@server2 pwd,但它不起作用:

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
Run Code Online (Sandbox Code Playgroud)

截屏

在此处输入图片说明

Raf*_*ski 36

我有完全相同的问题,我的解决方案是我从未想过的。在我的情况下,它rsync一直运行良好,直到在更改我的一个脚本后在某些测试中停止。罪魁祸首是我当前登录的 UNIX 用户位于已被脚本删除的不存在的文件夹中。

getcwd(): No such file or directory (2)错误消息是有关$PWD源,而不是目标。

只需将文件夹更改为现有文件夹(例如cd ~)并重新运行脚本。rsync如果路径还不是绝对路径,请不要忘记更改路径。

  • 我今天在设置两个文件夹之间的同步并收到此消息时遇到了非常相似的问题。源文件夹和目标文件夹显然存在。我检查了我是否可能在已删除的文件夹中,但这不是问题。但是我在目标文件夹中(这是一个 rclone 安装的 Google Drive)。我将我的工作目录更改为其他目录,并且同步工作完美而没有出现错误。 (2认同)