rsync -avP /home/user/.profile hpux3:/home/user/.profile
bash: rsync: command not found
Run Code Online (Sandbox Code Playgroud)
如果我对 hpux3 机器做了 ssh
rsync
version 3.1.1 protocol version 31
Copyright (C) 1996-2014 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
output truncated
Run Code Online (Sandbox Code Playgroud)
我已经设置PATH
了$HOME/.profile
和$HOME/.bashrc
。我应该在/etc/profile
文件中设置它吗?
Gil*_*il' 30
你.profile
当你登录交互是只读的。当 rsync 连接到另一台机器执行命令时,/etc/profile
并且~/.profile
不被读取。
如果您的登录 shell 是 bash,则~/.bashrc
可能会被读取(这是 bash 的一个怪癖——~/.bashrc
由非登录交互式 shell 读取,在某些情况下由登录非交互式 shell 读取)。但这并不适用于所有版本的 bash。
使 rsync 工作的最简单方法可能是传递--rsync-path
选项,例如
rsync --rsync-path=/home/elbarna/bin/rsync -avP /home/user/.profile hpux3:/home/user/.profile
Run Code Online (Sandbox Code Playgroud)
如果您使用基于密钥的身份验证通过 SSH 登录,则可以PATH
通过~/.ssh/authorized_keys
. 有关使用密钥通过 SSH 登录时如何安排加载的说明,请参阅ssh 上的 sh 启动文件.profile
。
小智 16
如果远程端未安装 rsync,则尝试将文件和目录从远程计算机同步到本地系统时也会发生此错误。
rsync -zarvh oem@172.20.0.12:/var/www/html/release /var/www/html/release
bash: rsync: command not found
Run Code Online (Sandbox Code Playgroud)
在远程端安装 rsync 将解决这种情况