对SVN更新脚本继续改进并增加定时任务
对之前的svn更新脚本继续改进,内容包括当无法连接SVN服务器时的处理,以及增加定时任务。
svn更新脚本改进之后代码如下:
#!/bin/shrevision=`svn info |grep "Last Changed Rev:" |awk '{print $4}'`echo "the revision is $revision"URL=`svn info |grep URL: |awk '{print $2}'`echo "the url is $URL"svnRevision=`svn info $URL |grep "Last Changed Rev:" |awk '{print $4}'`echo "the revision in svn is $svnRevision"if [[ $revision < $svnRevision ]] ; then echo -e "\033[0;31;40m need svn up \033[0m" svn up echo "svn up finish" exit 1elif [[ "$svnRevision" = "" ]]; then echo -e "\033[0;35;40m get svn revision info fail \033[0m" exit -1else echo -e "\033[0;38;40m no need svn up \033[0m" exit 0fi
echo $(cd "$(dirname "$0")"; pwd) #得到的是绝对路径echo ${0%/*} #得到的是相对路径,不过如果是在脚本所在目录运行该脚本,貌似得到的是运行的程序echo $(dirname `readlink -f "$0"`) #得到的是绝对路径
#!/bin/bashcd "$(dirname "$0")"ROOT=`pwd`LOGDIR=$ROOT/logsvnif [ ! -d "$LOGDIR" ]; then mkdir $LOGDIRfiFILENAME=$LOGDIR/$(date +%m%d%H%M%S).logfunction svnUp(){ echo "check $1" |tee -a $FILENAME cd $ROOT/$1 ./svnUpCheck.sh >> $FILENAME rtnvalue=$? if [[ $rtnvalue = 1 ]]; then echo -e "\033[0;31;40m svn up `pwd`\033[0m" elif [[ $rtnvalue = 0 ]]; then echo -e "\033[0;38;40m equal revision, skip `pwd`\033[0m" elif [[ $rtnvalue = -1 ]]; then echo -e "\033[0;35;40m can't get revision, skip `pwd`\033[0m" elif [[ $rtnvalue = 255 ]]; then echo -e "\033[0;35;40m unable to connect, error code: $rtnvalue \033[0m" else echo -e "\033[0;33;40m other error, error code: $rtnvalue \033[0m" fi revision=`svn info |grep "Last Changed Rev:" |awk '{print $4}'` changedate=`svn info |grep "Last Changed Date:" |awk '{print $4 "\x20" $5}'` echo "$revision $changedate" >> $FILENAME date >> $FILENAME echo >> $FILENAME}svnUp kernel/android/JBsvnUp kernel/linuxsvnUp kernel/systemsvnUp common_magellansvnUp image_file_creatorsvnUp systemsvnUp SQA_DailyBuild/AV_FWsvnUp SQA_DailyBuild/bootcode
/sbin/service crond start //启动服务 /sbin/service crond stop //关闭服务 /sbin/service crond restart //重启服务 /sbin/service crond reload //重新载入配置
/sbin/service crond start
0 9,12,15,18,21 * * * ~/branch/workspace/checkAllSVNUp.sh0 0 * * * ~/konka/makeimage.sh