svn设置定时提交
#!/bin/bash DIR="/home/wwwroot" #你的网站目录 Add_File="/home/lcf/add_file.list" #lcf是日志目录 Del_File="/home/lcf/del_file.list" Time=`date +%Y%m%d%H%M` LogFile="/home/lcf/$Time.log" cd $DIR
# 判断是否有新加文件 svn st | grep "? \+" | sed "s/? \+//" > $Add_File svn st | grep "! \+" | sed "s/! \+//" > $Del_File add_num=`cat $Add_File | wc -l ` del_num=`cat $Del_File | wc -l ` if [ $add_num == 0 ];then echo "no file add" >>$LogFile else echo "svn add" >>$LogFile
# 添加所有新文件 cat $Add_File | xargs svn add >>$LogFile fi if [ $del_num == 0 ];then echo "no file delete" >>$LogFile else echo "svn delete" >>$LogFile
# 删除所有本地缺失的文件 cat $Del_File | xargs svn delete >>$LogFile fi
#提交
svn ci -m 'auto commit by script' --username test --password test123 >>$LogFile rm $Add_File $Del_File
chmod 777 /usr/local/sbin/test.sh
vim /etc/crontab
* * * * * /usr/local/sbin/test.sh
systemctl restart crond.service
chkconfig crond on