summaryrefslogtreecommitdiff
path: root/templates/check-puppetd.sh.erb
diff options
context:
space:
mode:
Diffstat (limited to 'templates/check-puppetd.sh.erb')
-rw-r--r--templates/check-puppetd.sh.erb18
1 files changed, 11 insertions, 7 deletions
diff --git a/templates/check-puppetd.sh.erb b/templates/check-puppetd.sh.erb
index 1340315..d467ad6 100644
--- a/templates/check-puppetd.sh.erb
+++ b/templates/check-puppetd.sh.erb
@@ -49,14 +49,18 @@ function check_lockfile {
local pid process
if [ ! -z "$LOCKFILE" ] && [ -f "$LOCKFILE" ]; then
- pid="`cat $LOCKFILE`"
+ pid="`cat $LOCKFILE 2> /dev/null`"
process="`ps --no-headers -o comm $pid`"
- if [ "$?" == "0" ] && [ "`ps --no-headers -o comm $$`" == "$process" ]; then
- echo "Another backup is running for $LOCKFILE, skipping run"
- exit
- else
- echo "Found old lockfile $LOCKFILE, removing it"
- unset_lockfile
+
+ # Check lockfile again
+ if [ -f "$LOCKFILE" ]; then
+ if [ "$?" == "0" ] && [ "`ps --no-headers -o comm $$`" == "$process" ]; then
+ echo "Another backup is running for $LOCKFILE, skipping run"
+ exit
+ else
+ echo "Found old lockfile $LOCKFILE, removing it"
+ unset_lockfile
+ fi
fi
fi