diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-10-08 17:43:15 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-10-08 17:43:15 +0300 |
commit | e3fc150d54db3356460119fab7b165cc556294c0 (patch) | |
tree | f9187061140fe23b30fd403636e64e2f4cca8df7 /cron-runner.sh | |
parent | 19e7f1a44ed10873eba9b53c0bc7077304b0b75d (diff) |
Move cron wrapper scripts to top level, as they're not host-specific any more.
Change-Id: I7167cd3f2768a06dce9b4a8f80e0de8d494293de
Diffstat (limited to 'cron-runner.sh')
-rwxr-xr-x | cron-runner.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/cron-runner.sh b/cron-runner.sh new file mode 100755 index 0000000..0bf525a --- /dev/null +++ b/cron-runner.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# This script is intended to be run from crontab + +# Self-kill if run for more than 2 hours +(sleep 7200; if ps $$ >/dev/null; then kill -ALRM $$; fi)& + +BASE_DIR=/srv/mirror +MIRROR_DIR=$BASE_DIR/gerrit-mirror/ +LOG_DIR=$BASE_DIR/gerrit-mirror-logs/ + +if [ ! -d $MIRROR_DIR ]; then + mkdir -p $MIRROR_DIR +fi + +if [ ! -d $LOG_DIR ]; then + mkdir -p $LOG_DIR +fi + +TSTAMP=`date '+%Y%m%dT%H%M'` +MYPATH=. +LOG=$LOG_DIR/$TSTAMP-$1.log + +(time $MYPATH/git-gerrit-mirror --mirror-dir=$MIRROR_DIR $* >$LOG 2>&1) 2>>$LOG + +# Kill timeout process +kill %1 |