0

My .timer file located in ~/.config/systemd/user doesn't show in output of systemctl --user list-timers --all command unless i enable it. Is it normal for this command to not show disabled .timers alongside enabled ones?

I cannot enable the .timer without an [Install] section because of The unit files have no installation config error. According to freedesktop.org documentation:

Timer units will automatically have a dependency of type Before= on timers.target

Does this mean that i do not have to enable my .timer for it in order to work?

If i do need to enable my .timer:

I believe that default.target is what software which is to be executed after successful user login is WantedBy.

I also believe that the user systemd instance is started by pam_systemd, which i believe happens before default.target.

So it seems to me that if i use default.target the timer will be activated after login. If i use OnStartupSec in this case, will it correctly count the time from the startup of the systemd user instance?

On the other hand, if i use timers.target, since this is a user timer, will it be activated before login and start counting the seconds from its activation time, or it will just register and start counting time only after systemd --user is started?

2
  • You have to enable the timer for it to work.
    – muru
    Commented Apr 7, 2021 at 19:32
  • @muru My question is specifically for systemd user instance timers, the question you mentioned seems to be for systemd system instance timers. Since i've asked this question i've red more and will post my own answer, but feel free to add yours too.
    – Lyubomir
    Commented Apr 8, 2021 at 10:47

1 Answer 1

0

Since the time i've asked this question, i've red more and found out that my question was lying on a misconception from my side - i thought that both systemd's user and system instances rely on the same set of targets. According to THIS page each systemd instance uses its own set targets, so it's clear that the user timers do not activate before the user instance of systemd is started, so the timer will correctly count the time from the start of the systemd's user instance.

The system manager starts the [email protected] unit for each user, which launches a separate unprivileged instance of systemd for each user — the user manager. Similarly to the system manager, the user manager starts units which are pulled in by default.target. For non-graphical sessions, default.target is used. Whenever the user logs into a graphical session, the login manager will start the graphical-session.target target that is used to pull in units required for the graphical session. A number of targets (shown on the right side) are started when specific hardware is available to the user.

Since this is the case, i believe timers.target is the more appropriate of the two, but both should work.

Not the answer you're looking for? Browse other questions tagged .