Running a command before shutdown

424 views
Skip to first unread message

Andrei

unread,
Jan 17, 2017, 9:13:18 PM1/17/17
to CoreOS User
Hello guys,

I would like to run a command before shutdown, reboot on centos to send a:  /usr/bin/systemctl kill -s SIGUSR1 service-name.service.


have tried something like:

[Unit]
Description=Gracefully terminate the slave
DefaultDependencies=no
Before=shutdown.target reboot.target halt.target kexec.target

[Service]
Type=oneshot
ExecStart=/usr/bin/echo 'start' >> /root/worked.txt
ExecStop=/usr/bin/echo 'stop' >> /root/worked.txt
RemainAfterExit=yes

[Install]
WantedBy=shutdown.target reboot.target halt.target kexec.target


It doesn't seem to be working, I cant write anything in /usr/lib/systemd/system-shutdown/ due to the nature of CoreOS partitions.


Any way I can achieve this ?


David Michael

unread,
Jan 17, 2017, 9:25:43 PM1/17/17
to Andrei, CoreOS User
Hi,

On Tue, Jan 17, 2017 at 6:13 PM, Andrei
<andrei....@jobseeker.com.au> wrote:
> Hello guys,
>
> I would like to run a command before shutdown, reboot on centos to send a:
> /usr/bin/systemctl kill -s SIGUSR1 service-name.service.
>
>
> have tried something like:
>
> [Unit]
> Description=Gracefully terminate the slave
> DefaultDependencies=no
> Before=shutdown.target reboot.target halt.target kexec.target

This section should have Conflicts= with units that should stop your
service. Try removing the DefaultDependencies=no line, since
Conflicts=shutdown.target is the default behavior.

Thanks.

David
Reply all
Reply to author
Forward
0 new messages