Last active
February 27, 2024 23:06
-
-
Save yakaviuk/04fac5023c142b7217631069c77d4848 to your computer and use it in GitHub Desktop.
bash script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
service=$@ | |
/bin/systemctl -q is-active "$service.service" | |
status=$? | |
if [ "$status" == 0 ]; then | |
echo "OK" | |
else | |
/bin/systemctl start "$service.service" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
./watch-service.sh postgresql
Cron:
*/2 * * * * /opt/watch-service.sh postgresql > /dev/null