Templated unit-files
You can recognize this type of unit file by the @-sign that should be in its file name. For example: /etc/systemd/system/foo@.service
We can demonstrate its behavior in the following manner; Write the unitfile's contents:
/etc/systemd/system/foo@.service
:
[Unit]
Description=Will write "Foo %I" to journal
[Service]
ExecStart=/bin/echo "Foo %I"
(Load the new unit file using: $ sudo systemctl daemon-reload
)
Invoking actions on the unit file will result in the following behavior:
$ sudo systemctl start foo@bar.service
$ sudo systemctl status foo@choo.service
● foo@choo.service - Will write "Foo choo" to journal
Loaded: loaded (/etc/systemd/system/foo@.service; static; vendor preset: enabled)
Active: inactive (dead)
Aug 31 17:58:58 ranch-001 systemd[1]: Started Will write "Foo choo" to journal.
Aug 31 17:58:58 ranch-001 echo[31798]: Food choo
It will do this for any argument you'll pass after foo@
and before .service
.
$ sudo systemctl start foo@dabble.service
$ sudo systemctl status foo@dabble.service
● foo@dabble.service - Will write "Foo dabble" to journal
Loaded: loaded (/etc/systemd/system/foo@.service; static; vendor preset: enabled)
Active: inactive (dead)
Aug 31 18:09:15 ranch-001 systemd[1]: Started Will write "Foo dabble" to journal.
Aug 31 18:09:15 ranch-001 echo[32612]: Foo dabble
Let us know what you think