Enable a user .timer automatically

hi,
I have several .timer files that I’m putting under /var/home/core/.config/systemd/user with ignition. they seem to run fine, but they don’t seem to be auto enabled? how can I enable them on boot for the core user.
thanks.

I tested this under KDE F41.

If the .timer files have a WantedBy= then you can use systemctl --user enable.
This will symlink the systemd timer for you.

Here is an example of a user service (timers work the same way).

[Unit]
Description=qqq example

[Service]
Type=oneshot
ExecStart=/usr/bin/echo qqq example

[Install]
WantedBy=default.target

I then run systemctl --user daemon-reload to tell systemd about the new service.
Now I can enable the service:

systemctl --user enable --now qqq
Created symlink '/home/barry/.config/systemd/user/default.target.wants/qqq.service' → '/home/barry/.config/systemd/user/qqq.service'.

You can then use the ``systemctl --user list-timers` to check that your timer is enabled and working.

If you do not want to add the WantedBy= tags then you can symlink yourself into the ~/.config/systemd/user/default.target.wants folder.

1 Like

hi, yes, I can enable them manually fine, but I don’t want to do that, I want them automatically enabled on boot.
thanks

If you want the timers to run while not connected don’t forget to enable lingering for the core user.

loginctl enable-linger $USER

2 Likes

I think the closest (but not exactly you want to) is systemd.preset, which allows to specify the default status (enabled/disabled) for the units, but it still requires systemctl preset call.

Enabled means they will be started when you login.

You do the enable once to setup the symlink conveniently.

Now that the default.target has the timer wanted then it will be started at login.

ahh, that makes sense.

I was hoping to have the processes/quadlets automatically started and run, as a different user than root, but not having to log in.

actually this whole tutorial is exactly the use case I was looking for, ty.

oh didn’t know about preset, ty.

First preset is usually only useful if you are deploying systemd units to multiple systems. For one off installs I have never needed to use preset.

To allow none-root user services to run you at boot you can use linger mode. Use loginctl to enable linger for your user. Then when the system boots up it will start the user’s systemd services and timers.

Now when you login the services will already be running.
When you logout they will stay running.

For completeness you can also configure system services that run as a non-root user.

much thanks.