How to configure Systemd User Service with a Timer

Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
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.
arch-linux systemd services
add a comment |Â
up vote
2
down vote
favorite
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.
arch-linux systemd services
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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.
arch-linux systemd services
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.
arch-linux systemd services
arch-linux systemd services
asked Aug 23 '15 at 16:21
DominicM
249620
249620
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
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 at 9:13
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
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 at 9:13
add a comment |Â
up vote
0
down vote
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 at 9:13
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Does that answer what you need?
systemctl --user start unit.service
Does that answer what you need?
systemctl --user start unit.service
answered Aug 9 at 4:31
EarthMind
1234
1234
Adding some explanation why it would do so would be nice.
â phk
Aug 9 at 9:13
add a comment |Â
Adding some explanation why it would do so would be nice.
â phk
Aug 9 at 9:13
Adding some explanation why it would do so would be nice.
â phk
Aug 9 at 9:13
Adding some explanation why it would do so would be nice.
â phk
Aug 9 at 9:13
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f224954%2fhow-to-configure-systemd-user-service-with-a-timer%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password