39

I have a timer/service unit-set that should run once a day under --user conditions. It shows up with systemctl --user status and gets logged in journal but there is a part of the command that fails.

It seems that something in the command is not being interpreted correctly. I want to futz with the unit file and run the service, examine the log, etc to debug the issue; however editing the timer to trigger a minute in the future, waiting, and checking the log is... tedious.

Can do something like systemctl --user execute xxxxxx.service to just run the dang thing as if the timer triggered?

1 Answer 1

26

You can activate any unit manually, unless it contains a RefuseManualStart=yes and/or RefuseManualStop=yes directive (which do exactly what they say). Just issue systemctl --user start <whatever> (and systemctl --user stop <whatever> to do the opposite).

To quote systemctl(1):

start PATTERN...

Start (activate) one or more units specified on the command line.

<...>

stop PATTERN...

Stop (deactivate) one or more units specified on the command line.

4
  • Not working here: Failed to restart {foo}.service: Operation refused, unit {foo}.service may be requested by dependency only.
    – eMPee584
    Jul 9, 2019 at 18:01
  • 1
    @eMPee584 Since this answer was written, systemd gained new directives RefuseManualStart= and RefuseManualStop= (which do exactly what they say). I've updated my answer to mention that.
    – intelfx
    Jul 29, 2019 at 3:13
  • 1
    I tried this on the fstrim.timer. But for the timer it doesn't do anything. (enables it I think) When issued on fstrim.service, probably something happened. Is there no way to trigger the timer so it shows it was actually executed?
    – JPT
    Apr 10, 2020 at 12:13
  • 12
    @JPT "starting" a timer means that the timer starts ticking. Forcibly elapsing a timer is not supported in systemd. If you need this, just start the paired unit directly (in your case, fstrim.service).
    – intelfx
    Apr 12, 2020 at 3:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.