From: martin f. krafft Date: Sat, 20 Mar 2010 11:59:15 +0000 (+0100) Subject: implement lockfile handling X-Git-Url: https://git.madduck.net/etc/offlineimap.git/commitdiff_plain/92fd48ede228e9fdd93d57622bf86a584c66c25c?ds=inline;hp=8a99dcfaf1b4364abbeca1cc8392c81f2a33634a implement lockfile handling --- diff --git a/.bin/offlineimap b/.bin/offlineimap index 789fbe4..5bf7e52 100755 --- a/.bin/offlineimap +++ b/.bin/offlineimap @@ -1,6 +1,14 @@ #!/bin/sh set -eu +VAR=$HOME/.var/offlineimap +LOCKFILE="$VAR/.cron.lock" +trap "rm -f $LOCKFILE" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 +if ! lockfile -0 -r0 -l 3600 "$LOCKFILE" 2>/dev/null; then + echo "E: offlineimap is already running." >&2 + exit 1 +fi + if ! test -t 0; then echo Renicing because we are not run interactively… >&2 renice 20 -p $$ >/dev/null