Created
January 18, 2025 09:49
-
-
Save vodolaz095/484efe4fbd385185d50c0e454d32eabe to your computer and use it in GitHub Desktop.
Simple bash script to toggle on/off systemd service
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
#!/usr/bin/env bash | |
set -e | |
service="[email protected]" | |
if (systemctl -q is-active "$service") then | |
echo "Stopping $service..." | |
sudo systemctl stop "$service" | |
else | |
echo "Starting $service..." | |
sudo systemctl start "$service" | |
fi | |
systemctl status "$service" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment