Created
October 28, 2020 07:54
-
-
Save YouSysAdmin/ff34854b35d044f636e08f04eaedcf07 to your computer and use it in GitHub Desktop.
Systemd - Run before shutdown/reboot
This file contains 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
# systemd unit file | |
# /etc/systemd/system/run-before-shutdown.service | |
# TimeoutStartSec - set a timeout for your task or set "0" to disable. | |
# When the timeout is turned off and the task "hangs", | |
# the process will never be interrupted and the system | |
# shutdown will stop | |
# Before - Specify the services before which the task should run | |
# after add unit file in systemd/system catalogue, "run systemctl daemon-reload" | |
# and enable new service "systemctl enable run-before-shutdown.service" | |
[Unit] | |
Description=My task | |
DefaultDependencies=no | |
Before=shutdown.target | |
[Service] | |
Type=oneshot | |
ExecStart=/path_to/script.sh | |
TimeoutStartSec=0 | |
[Install] | |
WantedBy=shutdown.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment