Remove scriptherder from count

This commit is contained in:
Micke Nordin 2025-02-27 12:53:06 +01:00
parent 7090f7ca5e
commit dcb0ca8e48
Signed by untrusted user: Micke
GPG key ID: 0DA0A7A5708FE257

View file

@ -3,7 +3,8 @@
error_ids=""
# Only run if this is the only instance of this script running
# note: since this script forks to run pgrep, we need -eq 2 here
if [[ $(pgrep -f "${0}" | wc -l) -eq 2 ]]; then
# shellcheck disable=SC2126
if [[ $(pgrep -a -f "${0}" | grep -v scriptherder | wc -l) -eq 2 ]]; then
# We sleep a deterministic amount of time, which will be between 0 an 128 m and allways the same within
# a specific host, but will differ between hosts
sleep $((16#$(ip a | grep "link/ether" | head -1 | awk -F ':' '{print $6}' | awk '{print $1}') / 2))m
@ -21,7 +22,7 @@ if [[ $(pgrep -f "${0}" | wc -l) -eq 2 ]]; then
done
else
echo "Another instance of this script is already running, exiting"
pgrep -a -f "${0}"
pgrep -a -f "${0}" | grep -v scriptherder
exit 0
fi