I have a script that I want to run at logout/reboot and shutdown with a .service file in /etc/systemd/system
.
[Unit]
Description=My description
DefaultDependencies=no
Before=poweroff.target halt.target reboot.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/path/to/myscript.sh
[Install]
WantedBy=poweroff.target halt.target reboot.target
I have enabled the script with systemctl and it works on reboot and shutdown but not on logout. Is it doable?