I am using Fedora MATE 31. I want to configure a service to run after every user login.
I found some useful information here (among other sources).
Based on those I set up the following:
# create needed directory mkdir -p $HOME/.local/share/systemd/user # Use nano to write the service file shown below $ nano $HOME/.local/share/systemd/user/test1.service [Unit] Description=Testing On Login service [Service] Type=oneshot RemainAfterExit=true StandardOutput=journal ExecStart=/bin/sh -c "echo $(date) > /home/$USER/.date" [Install] WantedBy=default.target $ systemctl --user enable test1.service Created symlink /home/$USER/.config/systemd/user/default.target.wants/test1.service → /home/$USER//.local/share/systemd/user/test1.service. $ systemctl --user status test1 $ systemctl --user start test1 $ systemctl --user daemon-reload
After having reloaded the systemctl daemon I can do a
cat ~/.date and see that the service has run successfully.
I can then reboot the system and also see that the service has run successfully.
The problem is that if I then log out and log back in, the service doesn’t run again! How can I make the service run after a login no matter if it is the first login after booting or subsequent ones?
I tried changing
graphical.target but that didn’t help.