From 9ed6f63962728f38d59a68022609c2a4aaa5f3e8 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Tue, 13 Sep 2016 19:27:07 +0200 Subject: [PATCH] Added a lockfile --- updateWallpaper.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/updateWallpaper.sh b/updateWallpaper.sh index 9cf9ad6..6989ead 100755 --- a/updateWallpaper.sh +++ b/updateWallpaper.sh @@ -4,6 +4,7 @@ tags="scenic order:random width:1600" picdir=`realpath $(dirname "${BASH_SOURCE[0]}")` del="30m" sud=0 +lockfile=/tmp/updateWallpaper.lock for i in "$@"; do case $i in @@ -35,6 +36,15 @@ case $i in esac done +if [ -e "$lockfile" ]; then + echo "Error: Lock file $lockfile exists!" + echo " This most likely means another instance of the script is already running." + echo " Kill it and potentially delete the lock file after that using:" + echo " rm $lockfile" + exit 2; +fi +touch "$lockfile" + if [ "$sud" != "0" ]; then sleep "$sud"; fi