From 5e9d603e373edf318101eeadcfb44c6950156b1c Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Mon, 10 May 2021 20:06:08 +0800 Subject: [PATCH] fix: avoid a cron job running concurrently with itself If the time taken for the cronjob to run is longer than the period between jobs you can end up with dozens of cronjob processes running inside the pod. Since we already wrap the cron command, just add some locking to it so that only one instance of a cron job can run at once. --- images/commons/lagoon/cronjob.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/commons/lagoon/cronjob.sh b/images/commons/lagoon/cronjob.sh index a92c6cc76..b9faba0c6 100755 --- a/images/commons/lagoon/cronjob.sh +++ b/images/commons/lagoon/cronjob.sh @@ -11,4 +11,4 @@ trap exit_trap EXIT echo "$(date --utc +%FT%TZ) CRONJOB: $@" -/lagoon/entrypoints.sh sh -c "$@" +/lagoon/entrypoints.sh flock -n "/tmp/cron.lock.$(echo "$@" | sha256sum | awk '{ print $1 }')" sh -c "$@"