From 4c213f3de35822795d98daf7c8afddcf8c19b0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Pettersson?= Date: Sun, 4 Jun 2023 23:04:18 +0200 Subject: [PATCH] Create lockfiles for cronjob --- cron-scripts/10-test.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cron-scripts/10-test.sh b/cron-scripts/10-test.sh index 71937ad..e1079f6 100755 --- a/cron-scripts/10-test.sh +++ b/cron-scripts/10-test.sh @@ -1,5 +1,16 @@ #!/usr/bin/env -S guix shell bash -- bash +test -e /tmp/cron-10-test.sh.lock && find /tmp/cron-10-test.sh.lock -cmin +10 -delete + +if test -e /tmp/cron-10-test.sh.lock +then + echo "Lockfile exists" + exit 1 +fi + +echo "Creating lockfile" +touch /tmp/cron-10-test.sh.lock + set -x host_conf=$(hostname).scm @@ -18,7 +29,9 @@ then else echo "guix system reconfigure /etc/config.scm failure" cp -v "/etc/config.scm.backup" "/etc/config.scm" - exit 1 fi fi fi + +echo "Removing lockfile" +rm -fv /tmp/cron-10-test.sh.lock