Thank you for your really appreciated advice.
I confirm that I misunderstood what "applies to all instances" means.So now seems clear. Thanks
But there is something I don't understand.
I have two templates.The second one which is a simple instance of a tail > /dev/ttyX under ***@.serviceI renamed it to ***@.service (I don't have something which have foo* or bar* as name and previous ***@.service doesn't not exist anymore)
I have this [Install] Section:WantedBy=getty.targetDefaultInstance=tty12Alias=***@.service
systemctl enable ***@tty12.service> Created symlink /email@example.com => /etc/systemd/system/***@.service> Created symlink /firstname.lastname@example.org => /etc/systemd/system/***@service
Systemctl status ***@tty12.service> Loaded: error (Reason: Unit ***@tty12.service to load properly: File Exists)
Systemctl start ***@tty12.service = KO> Failed to start ***@tty12.service: Unit ***@tty12.service failed to load properly: File Exists.> See system logs and systemctl status ***@tty12.service for details
Systemctl start ***@tty12.service = OK
Le jeudi 22 avril 2021 Ã 20:49:52 UTC+2, Mantas MikulÄnas <***@gmail.com> a Ã©crit :
On Thu, Apr 22, 2021 at 9:18 PM Hans Gruber <***@yahoo.fr> wrote:
I am having problems with the aliases and "Alias=' directive related to the template service unit.
According to https://www.freedesktop.org/software/systemd/man/systemd.unit.html
I have exactly these two cases and requirements and cannot find example.
Â "A template may be aliased by another template (in which case the alias applies to all instances of the template)"
eg: How to create an alias using `Alias=` for a service template ***@.service which will have maybe 8 or 16 instances (eg: ***@cpu01.service ***@cpu02.service ..) which will apply to all instances when enabled using eg ***@.service.
I think you're misunderstanding what "applies to all instances" means. It does not give you a super-unit that controls all instances in unison -- rather, it gives you a template alias that will provide an alias for *each instance individually*.
But one instance is still aliased to one instance. For example, if you alias ***@.service => ***@.service, then you automatically get ***@cpu1.service => ***@cpu1.service, and so on. That's what template aliases do.
If you want to control multiple instances at once, you might be looking for two other features:1. Custom target units, which allow you to *start* all instances at once;
2. Wildcard support in `systemctl` commands, which allows you to see the status of all loaded instances at once (systemctl status "foo@*.service").