22.11.2016 12:34, Benoit SCHMID пишет: > Hello, > > On 11/22/2016 09:15 AM, Andrei Borzenkov wrote: >> Assuming that your command survives normal session exit - does adding >> "After=user.slice" to your service helps? This should ensure your >> service is stopped before any user processes. > > With "After=system.slice local-fs.target network-online.target > systemd-journald.socket user.slice basic.target", > my process is still killed by systemd before my stop script is started. >
Yes, it was my mistake. There is no systemd service unit *after* user sessions on startup (nor is it logically possible, as user sessions come and go). User session is represented by session-NNN.scope unit. On shutdown these units are stopped as soon as possible, according to general systemd behavior. These units are created on demand by logind; they have fixed dependencies, you cannot change them. It /may/ be possible to use drop-ins, except these names are not known in advance. There is no easy way to order something to be stopped first, just as there is no easy way to order something to be started last using systemd. It is possible to override special targets (poweroff.target etc) to pull in special service that will then trigger actual poweroff etc. This effectively means overriding vendor supplied systemd confguration; I doubt SAP would ever accept it as supported solution. _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel