[Unit] Description=Checks for (un)intended reboots. DefaultDependencies=no Wants=local-fs.target Before=shutdown.target After=local-fs.target Conflicts=shutdown.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=sh -c "rm /var/local/intended-reboot 2>/dev/null || echo 'Missing marker at '$(date) |mail -s 'Unintended reboot of '$(hostname) alarm@hostsharing.net" ExecStop=touch /var/local/intended-reboot [Install] WantedBy=multi-user.target