From d20f1aebd0a189de7dd485ab820b9f835da1e8b0 Mon Sep 17 00:00:00 2001 From: myvesta <38690722+myvesta@users.noreply.github.com> Date: Sun, 4 Apr 2021 18:48:41 +0200 Subject: [PATCH] Preventing multiple execution of v-backup-users --- bin/v-backup-users | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/v-backup-users b/bin/v-backup-users index 640c1916..5b9f75f4 100755 --- a/bin/v-backup-users +++ b/bin/v-backup-users @@ -4,6 +4,14 @@ # # The function backups all system users. +scriptname="v-backup-users" +pidof -x "$scriptname" +for pid in $(pidof -x "$scriptname"); do + if [ $pid != $$ ]; then + echo "[$(date)] : $scriptname : Process is already running with PID $pid" + exit 1 + fi +done #----------------------------------------------------------# # Variable&Function #