Skip to content

Instantly share code, notes, and snippets.

@trydofor
Created April 23, 2018 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trydofor/751b1b7e4caddf9f641a222d949738e7 to your computer and use it in GitHub Desktop.
Save trydofor/751b1b7e4caddf9f641a222d949738e7 to your computer and use it in GitHub Desktop.
判断主机和程序,rsync目录
#!/bin/bash
master_host=jiayu-app-master
master_ip=`grep $master_host /etc/hosts | awk '{print $1}'`
master_here=`ifconfig -a | grep $master_ip`
this_host=""
that_host=""
if [ -z "$master_here" ]; then
this_host="jiayu-app-slave"
that_host="jiayu-app-master"
else
this_host="jiayu-app-master"
that_host="jiayu-app-slave"
fi
deerex_here=`ps -ef | grep deerex | grep -v grep`
# 如果不存在,就从对方拉
if [ -z "$deerex_here" ]; then
rsync -azP ubuntu@$that_host:/data/deerex-fedex-label/ /data/deerex-fedex-label/
fi
takeex_here=`ps -ef | grep takeex | grep -v grep`
# 如果不存在,就从对方拉
if [ -z "$takeex_here" ]; then
rsync -azP ubuntu@$that_host:/data/takeex-upload/ /data/takeex-upload/
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment