From 5c85f3d57b099084ad9cc44b873cd7deb36cdfae Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Wed, 21 Feb 2024 09:31:46 -0500 Subject: [PATCH] script to test service and start if not --- scripts/systemctl-alive.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 scripts/systemctl-alive.sh diff --git a/scripts/systemctl-alive.sh b/scripts/systemctl-alive.sh new file mode 100644 index 0000000..6cee2a9 --- /dev/null +++ b/scripts/systemctl-alive.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# crontab -e +# * * * * * /bin/bash /etc/template_setup/scripts/systemctl-alive.sh + +service=$@ +/bin/systemctl -q is-active "$service.service" +status=$? +if [ "$status" == 0 ]; then + echo "OK" +else + /bin/systemctl start "$service.service" +fi