Hi,

Could you please advise me with regard to systemd configuration for service
type=oneshot.
It does not execute stop on shutdown/reboot, but works as intended when
called manually.

Online discussions indicate that the configuration below should be working.

1) service configuration:
[Unit]
Description= ### service test ###

[Service]
ExecStart=/tmp/aaa.sh start
ExecStop=/tmp/aaa.sh stop
Type=oneshot
RemainAfterExit=yes
TimeoutStopSec=100

[Install]
WantedBy=multi-user.target default.target


2) Tried also:
WantedBy=shutdown.target ...



3) # systemctl status xdctest
● xdctest.service - ### service test ###
   Loaded: loaded (/etc/systemd/system/xdctest.service; enabled; vendor
preset: disabled)
   Active: active (exited) since Mon 2018-08-20 22:43:21 UTC; 1min 13s ago
  Process: 22304 ExecStop=/tmp/aaa.sh stop (code=exited, status=0/SUCCESS)
  Process: 22407 ExecStart=/tmp/aaa.sh start (code=exited, status=0/SUCCESS)
 Main PID: 22407 (code=exited, status=0/SUCCESS)

Aug 20 22:43:01 ip-10-43-215-250.ec2.internal systemd[1]: Starting ###
service test ###...
Aug 20 22:43:01 ip-10-43-215-250.ec2.internal aaa.sh[22407]: BEGIN: TESTING
systemd: start
Aug 20 22:43:21 ip-10-43-215-250.ec2.internal aaa.sh[22407]: END:   TESTING
systemd: start
Aug 20 22:43:21 ip-10-43-215-250.ec2.internal systemd[1]: Started ###
service test ###.



4) # systemctl --version
systemd 219
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP
+GCRYPT +GNUTLS +ACL +XZ +LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN



5) OS: GNU Linux, CentOS 7


Thanks in advance,

-- 
Radoslaw Garbacz
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to