#!/bin/bash
source_dir="/www/wwwroot/" # 本地目录
destination_dir="IP:/www/wwwroot/" # IP:远程目录
ssh_password="" # 替换为你的SSH密码
log_file="/root/rsync.log" # 日志存储
nohup rsync -avz --update -e "sshpass -p '$ssh_password' ssh -p 端口号" --inplace "$source_dir" "$destination_dir" > "$log_file" 2>&1 &
#!/bin/bash
# 监控rsync脚本
pid2=$(pgrep -f rsync)
if [ -z "$pid2" ]; then
bash /www/wwwroot/脚本运行路径 > /dev/null 2>&1 &
else
echo "Rsync_sync 已在运行中 PID $pid2."
fi