From bb677951f55b884d53ebd0ae52d3d3760aabca78 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 15 Apr 2024 13:39:35 +0200 Subject: doalogwatch: only check backups if not called by shutdownasap -q * shutdownasap -q does its own check - do not wait again for the backups --- doalogwatch.in | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/doalogwatch.in b/doalogwatch.in index 1b0c662..f3b312d 100755 --- a/doalogwatch.in +++ b/doalogwatch.in @@ -50,17 +50,20 @@ while ${warten} && [ "$(date '+%H')" != '23' ]; do warten=true # check for currently running backups - pgrep -xf "(#BINDIR#/)?backup( .*)?" >/dev/null && \ - warten=true - if [ -r '#ETCDIR#/backup.conf' ]; then - for i in 1 2; do - for id in "${!backups[@]}"; do - [ -s "#TMPDIR#/${id}.pid" ] && \ - kill -0 $(cat "#TMPDIR#/${id}.pid") 2>/dev/null && \ - warten=true + ppid=$(awk '$1 == "PPid:" {print $2}' /proc/$$/status) + if [ ! "$(tr '\0' ' ' <"/proc/${ppid}/cmdline")" = '/bin/bash /usr/bin/shutdownasap -q ' ]; then + pgrep -xf "(#BINDIR#/)?backup( .*)?" >/dev/null && \ + warten=true + if [ -r '#ETCDIR#/backup.conf' ]; then + for i in 1 2; do + for id in "${!backups[@]}"; do + [ -s "#TMPDIR#/${id}.pid" ] && \ + kill -0 $(cat "#TMPDIR#/${id}.pid") 2>/dev/null && \ + warten=true + done + sleep 1 done - sleep 1 - done + fi fi done -- cgit v1.2.3-70-g09d2