[systemd-devel] how to run a script which takes about 30 seconds before shutdown

Lennart Poettering lennart at poettering.net
Fri Nov 11 12:44:02 UTC 2016


On Wed, 09.11.16 21:11, zerons (sironhide0null at gmail.com) wrote:

> Hi everyone.
> 
> Everyday, I need to do something like `git pull` after system
> bootup and `git push` before shutdown. I am using Ubuntu 16.04.
> I have tried to put some script into /etc/rc0.d/, /etc/rc6.d/,
> each time the script runs, the network has been stopped, so I 
> turn to systemd.
> 
> 
> === Here is a test .service file.
> [Unit]
> Description=test systemd
> Conflicts=reboot.target
> After=network-online.target
> Wants=network-online.target

If you only care about shutdown, then After=network.target shouls
suffice, as long as your network management service properly orders
itself against that. See systemd.special(7) for details on this.

Note that systemd only provides a number of hooks we document
semantics for, but it's up to downstream packages to actually honour
these correctly.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list