rsync命令在从远程SSH执行时不起作用。

huangapple go评论54阅读模式
英文:

rsync command is not working when executing from remote ssh

问题

以下是要翻译的内容:

从远程主机执行时,rsync命令无法正常工作。Jenkins节点尝试在远程服务器上执行一些命令,但在运行rsync命令时,我收到以下错误消息
sh: rsync: 未找到命令。

当我直接在该服务器上运行rsync命令时,它能够成功工作,但通过ssh运行时,会出现上述错误。

以下是出现问题的命令

ssh root@"$build_server" "rsync -avzh $SRC_DIR/main $BUILD_DIR || exit 1"

我尝试通过提供rsync的路径,但仍然出现相同的错误

ssh root@"$build_server" "rsync -avzh --rsync-path=/usr/local/bin/rsync $SRC_DIR/main $BUILD_DIR || exit 1"
英文:

rsync command is not working when executing it from a remote host. Jenkins node tries to execute few commands on a remote server, but when running the rsync command I am getting below error
sh: rsync: not found.

The rsync command works successfully when I run directly on that server, but when I run it through ssh, it is giving the above error

This is the command that is failing

ssh root@"$build_server" "rsync -avzh $SRC_DIR/main $BUILD_DIR || exit 1"

I tried by giving the path of rsync but still the same error

ssh root@"$build_server" "rsync -avzh --rsync-path=/usr/local/bin/rsync $SRC_DIR/main $BUILD_DIR || exit 1"

答案1

得分: 1

检查远程服务器的PATH环境变量:Jenkins在shell环境中执行命令,错误提示表明shell找不到rsync可执行文件。请确保远程服务器上的PATH环境变量已正确设置。

echo $PATH

因此,您可以修改您的环境或指定rsync可执行文件的完整路径:如果rsync安装在非标准位置或PATH设置不正确,您可以在Jenkins作业或脚本中指定rsync可执行文件的完整路径。

/usr/bin/rsync [选项] 源目录 目标目录
英文:

Check the remote server's PATH environment variable: Jenkins executes commands in a shell environment, and the error indicates that the shell cannot find the rsync executable. Ensure that the PATH environment variable is properly set on the remote server.

echo $PATH

So either you modify your environment or you specify the full path to the rsync executable: If rsync is installed in a non-standard location or the PATH is not set correctly, you can specify the full path to the rsync executable in your Jenkins job or script.

/usr/bin/rsync [options] source destination

huangapple
  • 本文由 发表于 2023年5月22日 15:32:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76303903.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定