[systemd-devel] At wits end... need to execute a script prior to anything getting killed/changed on reboot/shutdown
Christopher Cox
ccox at endlessnow.com
Wed Jan 16 18:40:37 UTC 2019
I need to be able to execute a script before anything gets shutdown. That is,
when somebody does a "reboot", "shutdown" or "poweroff", I need this script to
run first, and for it to finish before everything gets whacked.
I know the following isn't "right"... I've tried so many different things.
Google hasn't helped only giving me many "right" solutions that didn't work. In
this current edition, basically I get a partial capture of processes that are
running (that is some were killed directly or indirectly).. I need them all. My
script needs to see the state of operation before reboot/shutdown/poweroff do
anything else. My "save" saves some information about running processes (some
not necessarily under systemd control).
[Unit]
Description=my-service save status
DefaultDependencies=no
Before=reboot.target shutdown.target
Conflicts=reboot.target shutdown.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
ExecStop=/usr/local/bin/my-service.sh save
StandardOutput=journal
[Install]
WantedBy=multi-user.target
More information about the systemd-devel
mailing list