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 [email protected] [Install] WantedBy=timers.target
What confuses me is what to put in the "Unit=". If I put in "[email protected]" it works but then it will always run as a single user defeating the point of having a multi user service. Using "[email protected]" 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.