Skip to content

Instantly share code, notes, and snippets.

@vodolaz095
Created January 18, 2025 09:49
Show Gist options
  • Save vodolaz095/484efe4fbd385185d50c0e454d32eabe to your computer and use it in GitHub Desktop.
Save vodolaz095/484efe4fbd385185d50c0e454d32eabe to your computer and use it in GitHub Desktop.
Simple bash script to toggle on/off systemd service
#!/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