systemctl edit reboot.target systemctl edit soft-reboot.target systemctl edit ctrl-alt-del.target systemctl edit poweroff.target
and change
[Unit] JobTimeoutSec=30min
or use unit override files.
Drawbacks: If service is scheduled before shutdown.target it is started too late for some complex operation. Almost all services are stopped, tmpfs are unmounted and filesystems are remounted RO.
[Unit] Description=Disable power output DefaultDependencies=no After=enable-power.service another-enable-power.service Conflicts=enable-power.service another-enable-power.service Before=shutdown.target reboot.target halt.target kexec.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=/bin/power_control disable [Install] WantedBy=shutdown.target WantedBy=reboot.target WantedBy=halt.target WantedBy=kexec.target
Trick is to provide service without ExecStart=
action only to provide
correct ordering for ExecStop=
action.
From systemd.unit
doc:
When two units with an ordering dependency between them are shut down, the inverse of the start-up order is applied Most importantly, for service units start-up is considered completed for the purpose of Before=/After= when all its configured start-up commands have been invoked and they either failed or reported start-up success
[Unit] Description=Disable power output DefaultDependencies=no # Shedule it BEFORE to run ExecStop AFTER during shutdown Before=enable-power.service # Want to run ExecStop after eley-device is stopped Before=another-enable-power.service Before=basic.target After=sysinit.target local-fs.target Before=shutdown.target reboot.target halt.target kexec.target Conflicts=shutdown.target reboot.target halt.target kexec.target [Service] Type=oneshot RemainAfterExit=yes ExecStop=/bin/power_control disable ExecStop=/bin/true [Install] WantedBy=basic.target