Quantcast
Channel: How to execute scripts in /usr/lib/systemd/system-shutdown/ at reboot or shutdown? - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 3

How to execute scripts in /usr/lib/systemd/system-shutdown/ at reboot or shutdown?

$
0
0

According to this answer and this bug report one can simply drop your script in

/usr/lib/systemd/system-shutdown/

or for Debian in

/lib/systemd/system-shutdown/

to have it executed at reboot or shutdown. From

https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html:

Immediately before executing the actual system halt/poweroff/reboot/kexec systemd-shutdown will run all executables in /usr/lib/systemd/system-shutdown/ and pass one arguments to them: either "halt", "poweroff", "reboot" or "kexec", depending on the chosen action. All executables in this directory are executed in parallel, and execution of the action is not continued before all executables finished.

My script is described at How to run a script at shutdown on Debian 9 or Raspbian 8 (Jessie) as:

#!/bin/sh
touch /test

However, it didn't seem to run on my Debian systems and I even reported it as bug.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images