I am a bit confused by systemd user services.
I have two service files in ~/.config/systemd/user/ as follows:-
-rw-rw-r-- 1 chris chris 184 Jan 29 18:14 fblcd@chris.service
-rw-rw-r-- 1 chris chris 178 Jan 27 21:32 helmlcd.service
The differences in fblcd@chris.service are just the description and
the executable file:-
[Unit]
Description=Run the Flying Bridge display
[Service]
Type=simple
StandardOutput=journal
ExecStart=/home/chris/bin/fblcd.py
Restart=on-failure
[Install]
WantedBy=default.target
Both are installed and run (using systemctl) in the same way, so
what's the difference between them? What does the @chris do, if
anything?
These are both written by me so they may very likely be misconfigured
in some way. :-) They are running on a headless system and I want
them to run when the system is [re]booted. They run continuously
displaying electrical values on two LCD displays.
If you only use one instance and never make use of the string expansion
then it has no effect.
These are both written by me so they may very likely be misconfigured
in some way. :-) They are running on a headless system and I want
them to run when the system is [re]booted. They run continuously displaying electrical values on two LCD displays.
Is there a reason you chose to use '@chris' in the service file name
without knowing what it does?
So, if I understand correctly, when I do:-
systemctl --user start helmlcd.service
Then, although it has been started by 'chris' (I'm logged in as
chris), only one copy of the service can be run.
However, when I do:-
systemctl --user start fblcd@chris.service
it's quite possible for others to start their own copies of the
service, though presumably they'd have to have a copy of the service
file called fblcd@othername.service.
How does the second differ from simply having services called chrisfblcd.service, othernamefblcd.service and so on?
Hi,
On Thu, Jan 29, 2026 at 08:28:47PM +0000, Chris Green wrote:
So, if I understand correctly, when I do:-
systemctl --user start helmlcd.service
Then, although it has been started by 'chris' (I'm logged in as
chris), only one copy of the service can be run.
Only one copy by user chris, yes. It's not a templated service. If you
want multiple of them running as user services of chris then you'd have
to copy the .service file to a new name, making the copy effectively a completely separate and different service.
As it's a user service, it's expected that a DIFFERENT user could also
run it.
However, when I do:-
systemctl --user start fblcd@chris.service
it's quite possible for others to start their own copies of the
service, though presumably they'd have to have a copy of the service
file called fblcd@othername.service.
As long as there is a fblcd@.service template file somewhere in
systemd's search paths (for user units), then if a user does:
myusername$ systemctl --user start fblcd@foo
Then they should get their own instance of this service. It may be a requirement of the service that "foo" is actually the username, or it
might not be, leaving it to just be an arbitrary instance name. As this
is a templated user service there is in principle no reason why a single
user can't run multiple instances of it. There might be some
service-specific reason why each user can only run one.
The "start" command with an instance name should copy the .service file
from the template.
How does the second differ from simply having services called chrisfblcd.service, othernamefblcd.service and so on?
There only has to be one template unit file somewhere called
fblcd@.service rather than every user having to copy their own one into place. Also the fact that it's a template indicates that it's expected
that multiple copies of it are in some way catered for.
| Sysop: | Jacob Catayoc |
|---|---|
| Location: | Pasay City, Metro Manila, Philippines |
| Users: | 5 |
| Nodes: | 4 (0 / 4) |
| Uptime: | 20:50:37 |
| Calls: | 117 |
| Calls today: | 117 |
| Files: | 367 |
| D/L today: |
559 files (257M bytes) |
| Messages: | 70,875 |
| Posted today: | 26 |