Created
April 23, 2018 06:11
-
-
Save trydofor/751b1b7e4caddf9f641a222d949738e7 to your computer and use it in GitHub Desktop.
判断主机和程序,rsync目录
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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