2

I have a systemd user service that works as expected. It is started like this:

systemctl start test@user

The problem is that I need to run this service on a timer possibly for multiple users. There doesn't seem to be a way to specify a user in the timer itself or a way to pass the username with the @ notation.

Here is the timer:

[Unit]
Description=Test (runs once every 24 hours)

[Timer]
OnUnitActiveSec=24h
Persistent=true
Unit=test@.service

[Install]
WantedBy=timers.target

What confuses me is what to put in the "Unit=". If I put in "test@user.service" it works but then it will always run as a single user defeating the point of having a multi user service. Using "test@.service" starts the timer but "systemctl status test@user" shows it as always inactive even with timer set to 1min interval.

I am not sure how to list the all running instances of a given systemd service so I don't know if "test@" service is running as a different user when a timer runs the service without the "@user".

What is the proper way to start user services with a timer? Ideally users should be able to create and manage their own services as well as timers that go along those services.

0

Does that answer what you need?

systemctl --user start unit.service
  • Adding some explanation why it would do so would be nice. – phk Aug 9 '18 at 9:13

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.