I wrote a tiny custom
.service module to capture the date and time when my containers shutdown. The reason: I’m chasing a different problem w/ my setup, so knowing the time of shutdown would be useful.
systemctl enable and
systemctl start as required. However, after booting the container, the service isn’t active:
systemctl status myNewService shows it as “inactive (dead).”
I also see the following error message: “myNewService.service: Failed to reset devices.list: Operation not permitted”
If I use
systemctl restart, the status switches to “active (exited)” and the error message drops away.
Also, the service actually does what it should do at shutdown when it is active.
I would appreciate any help.
Specs: Ubuntu 18.04 host w/ Ubuntu 18.04 containers.
The service unit file looks like this
Before=shutdown.target reboot.target halt.target kexec.target
ExecStop=/path/to/my/custom/script # <-- executable, of course
WantedBy=shutdown.target reboot.target halt.target kexec.target