17.05.2020 03:32, Michael Chapman пишет: > On Fri, 15 May 2020, Frank Steiner wrote: >> Hi, >> >> I need to run a script on shutdown before any other service is stopped. >> Due to an advice Lennart gave a while ago I'm using this service file >> (with multi-user.target being our default runlevel target): >> >> [Unit] >> After=multi-user.target >> >> [Service] >> Type=oneshot >> ExecStart=/bin/true >> ExecStop=/usr/lib/systemd/scripts/halt.local.bio >> TimeoutSec=120 >> RemainAfterExit=yes > > This seems inherently fragile. > > If `multi-user.target` were to be stopped for whatever reason (and this > is generally possible), the ordering dependencies between services > Before=multi-user.target and services After=multi-user.target are broken. This is universally true. Do you have suggestion how it can be done differently? Even if multi-user.target is manually stopped, there is no way normal service can be stopped concurrently with local filesystems, simply because normal service is always ordered After=basic.target. Unless of course we manually stop basic.target and sysinit.target as well :) I cannot reproduce it using trivial service definition on openSUSE Leap 15.1 which should have the same systemd as SLE 15 SP1. So possibilities are 1. Something in unit definition triggers some bug in systemd. In this case exact full unit definition is needed. Also shutdown log with debug log level will certainly be useful. 2. ExecStop command is not synchronous, it forks and continues in background. In this case probably systemd assumes unit is stopped and continues. Again, log with debug log level would confirm it. _______________________________________________ systemd-devel mailing list systemd-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/systemd-devel