From: Steinar H. Gunderson Date: Wed, 8 Oct 2014 08:41:24 +0000 (+0200) Subject: Fix a bug where the lock file would be removed if seen from a different process. X-Git-Url: https://git.sesse.net/?p=backup.sh;a=commitdiff_plain;h=d3303892e4f393d994804016060a8bc704acfebb Fix a bug where the lock file would be removed if seen from a different process. --- diff --git a/backup.sh b/backup.sh index 29ffa1f..f4ae98b 100755 --- a/backup.sh +++ b/backup.sh @@ -68,9 +68,10 @@ infomsg() { # Trap C-c and kill trap die SIGINT SIGTERM -# Don't start if we're already running +# Don't start if we're already running. Don't use diemsg, as that removes the lock file! if [ -e $LOCKFILE ]; then - diemsg "$LOCKFILE exists for pid `cat $LOCKFILE`." + warnmsg "$LOCKFILE exists for pid `cat $LOCKFILE`." + exit 1 fi; touch $LOCKFILE echo $$ > $LOCKFILE