[Unit] Description=Run command before shutdown DefaultDependencies=no Before=shutdown.target reboot.target halt.target [Service] Type=oneshot ExecStart=/bin/true ExecStop=/usr/local/bin/pre-shutdown.sh RemainAfterExit=yes [Install] WantedBy=multi-user.target