git pull 自动拉去分支版本
/usr/local/git/bin/git 最好写全路径!
遇到的坑: 手动执行sh脚本没问题, 在crontab里面无法找到git, 一直无法执行pull
#!/bin/bash echo '' echo '=======================' echo `date +"%Y-%m-%d %H:%M:%S"` #cd /www/wwwroot/angel_web/web #git pull origin master branch_name=`cd /www/wwwroot/angel_web/web && /usr/local/git/bin/git branch | grep '^*' | awk '{print $2}'` # echo ${branch_name} if [ ${branch_name} = 'master' ];then cd /www/wwwroot/angel_web/web && /usr/local/git/bin/git pull origin master else echo 'not master' fi echo '=== end ==='
crontab
* * * * * /root/sh/angel.sh >> /root/sh/ag.log