Running a systemd user service before shutdown

Ah yes … makes sense multi-user.target is not user either.
I had of course adapted it from a non-user service.
default.target however should work.

[Unit]
Description=Pushing commits for emacs config at shutdown

[Service]
Type=oneshot
RemainAfterExit=true
StandardOutput=journal
ExecStop=/home/esbon1253/scripts/epush.sh 'commit before shutdown'

[Install]
WantedBy=default.target

Then do the same things:

systemctl daemon-reload && systemctl --user enable before-shutdown.service

(though note that this is technically before logout … please advise if this is undesirable)

3 Likes