Systemd timer - message

I got the following message while activating the systemd timer I’ve created:

sudo systemctl enable ascio_invoices.service
The unit files have no installation config (WantedBy=, RequiredBy=, UpheldBy=,
Also=, or Alias= settings in the [Install] section, and DefaultInstance= for
template units). This means they are not meant to be enabled or disabled using systemctl.
 
Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
  .wants/, .requires/, or .upholds/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
  instance name specified.

and here is my setup :

/etc/systemd/system/ascio_invoices.service

[Unit]
Description=Ascio Rechnungsseiten bündeln

[Service]
WorkingDirectory=/home/suther/ascio_converter/
ExecStart=/home/suther/ascio_converte/ascio_invoiceCombiner.sh
User=suther

/etc/systemd/system/ascio_invoices.timer

[Unit]
Description=Ascio-Rechnungen automatisch konvertieren

[Timer]
OnCalendar=*:0/5
Unit=ascio_invoices.service

[Install]
WantedBy=timers.target

then in bash:

systemctl enable ascio_invoices.service
sudo systemctl start ascio_invoices.timer

Check = systemctl list-timers:

NEXT                            LEFT LAST                              PASSED UNIT                             ACTIVATES
Fri 2023-12-01 16:20:00 CET 2min 51s Fri 2023-12-01 16:15:15 CET 1min 52s ago ascio_invoices.timer             ascio_invoices.service

I don’t see, why this notification (I’ve posted at the beginning) was thrown, as I do have an [Install]-Section in my .timer-File.

You don’t enable the service, you enable the timer.

1 Like

Ok, what do I have to put in there? Don’t fully understand that WantedBy section.

Noting, you change your systemctl enable from the service to the timer.

I don’t see, what you mean with that. Can you explain this a bit more in detail?

sudo systemctl enable --now ascio_invoices.timer

The --now makes the unit start immediately, not wait until next boot.

ok, but then

sudo systemctl enable ascio_invoices.service

is just fine for next reboot, or am I wrong?
Anyway I don’t understand why this command throw this warning.

Do NOT use this line, use:

If you want to wait and don’t want to activate the timer until next reboot, remove the --now

1 Like

Ok, thanks. To conclude:

I should use

sudo systemctl enable --now ascio_invoices.timer

as this has the benefit, not only to work after next reboot, but also start the timer now.

But can you tell me… if the only difference of using parameter -now is the fact, that the timer immediately start… why do I got an error for the command without now?

I don’t see the logic behind… especially as the service-file is exactly the same, and contain an [Install]-Section.

Because you’re enabling the service, not the timer.

The service is designed to be started by the timer, not on it’s own, so it lacks an install section.

The install section is needed if you use the service directly.

2 Likes

Are you dyslectic like me? xD

sudo systemctl enable ascio_invoices.service # your line
sudo systemctl enable ascio_invoices.timer # the correct line

See the difference now?

And yes, that is the only difference with using --now, it starts directly.
It’s the same as not using --now and then typing:

sudo systemctl start ascio_invoices.timer

after you have enabled it.

1 Like

:man_facepalming: :laughing:

Thx.

1 Like

If you’re going to use a systemd timer for something to do with your user account, then you should not start it with sudo, but rather as a --user service or timer. See… :point_down:

man systemctl
4 Likes

This topic was automatically closed 3 hours after the last reply. New replies are no longer allowed.