记录mercurial事务
这是对上一个脚本的一个小补充,这次我想记录备份的详细信息记录mercurial事务,mercurial,shell,Mercurial,Shell,这是对上一个脚本的一个小补充,这次我想记录备份的详细信息 script /tmp/commit-push-log # add all files to the repository for REPOSITORY in $@ do cd $REPOSITORY # commit the changes hg commit -A -m "Commit changes `date`" # push the changes to the remote repos
script /tmp/commit-push-log
# add all files to the repository
for REPOSITORY in $@
do
cd $REPOSITORY
# commit the changes
hg commit -A -m "Commit changes `date`"
# push the changes to the remote repository
if hg push
then
logger hg push completed without failure
else
logger hg push fails
fi
done
exit
cat /tmp/commit-push-log | logger
rm /tmp/commit-push-log
问题是我在日志中没有看到任何mercurial消息。我的脚本中会出现什么错误?我的当前版本
for REPOSITORY in $@
do
# new temp file
OUTPUT_LOG=`tempfile`
echo -n > $OUTPUT_LOG
# checks whether $REPO is a repo
if [ ! -d $REPOSITORY/.hg ]; then
echo "Not a repository: $REPOSITORY"
exit 1;
fi
# change to that dir
cd "$REPOSITORY"
logger "Repository: $REPOSITORY"
# commit the changes
hg commit -A -m "Commit changes `date`" 2>&1 >> $OUTPUT_LOG
# push the changes to the remote repository
if hg push 2>&1 >> $OUTPUT_LOG
then
logger hg push completed without failure
else
logger hg push fails
exit 1;
fi
# log the contents and delete the tempfile
cat $OUTPUT_LOG | logger
rm -f $OUTLOG_LOG
done
exit 0
cd“$REPOSITORY”
而不是“cd$REPOSITORY”,否则当存储库包含任何空格或特殊字符时,事情会变得有趣hg commit-A-m“$comment”2>&1
和hg push 2>&1
该脚本主要用于备份/var/log和/etc,以便从外部服务器进行监控,因此自动提交注释应该足以满足您没有正确引用$OUTPUT\u log和第10行$REPOSITORY/.hg的目的。尝试导出TMPDIR=“/tmp/space test”;mkdir“$TMPDIR;。/你的脚本`#明白我的意思。
tempfile
的+1不知道那个。