Skip to content

Instantly share code, notes, and snippets.

@zealws
Last active February 27, 2018 23:19
Show Gist options
  • Save zealws/adfe79645837169fbf09fb40066b15ab to your computer and use it in GitHub Desktop.
Save zealws/adfe79645837169fbf09fb40066b15ab to your computer and use it in GitHub Desktop.
# /etc/systemd/system/hello@.service
[Unit]
Description=say hello
OnFailure=hello2.service
[Service]
Type=oneshot
ExecStart=/bin/echo "%I"
ExecStart=/bin/echo "%i"
zeal@epona /etc/systemd/system $ sudo systemctl start "hello@foo-bar.service"
zeal@epona /etc/systemd/system $ sudo systemctl status "hello@foo-bar.service"
● hello@foo-bar.service - say hello
Loaded: loaded (/etc/systemd/system/hello@.service; static; vendor preset: disabled)
Active: inactive (dead)
Feb 27 15:11:52 epona systemd[1]: Starting say hello...
Feb 27 15:11:52 epona echo[22733]: foo/bar
Feb 27 15:11:52 epona echo[22734]: foo-bar
Feb 27 15:11:52 epona systemd[1]: Started say hello.
zeal@epona /etc/systemd/system $ sudo systemctl start 'hello@/foo-bar/baz.service'
zeal@epona /etc/systemd/system $ sudo systemctl status 'hello@/foo-bar/baz.service'
● hello@-foo-bar-baz.service - say hello
Loaded: loaded (/etc/systemd/system/hello@.service; static; vendor preset: disabled)
Active: inactive (dead)
Feb 27 15:04:58 epona systemd[1]: Starting say hello...
Feb 27 15:04:58 epona echo[22138]: /foo/bar/baz
Feb 27 15:04:58 epona echo[22139]: -foo-bar-baz
Feb 27 15:04:58 epona systemd[1]: Started say hello.
zeal@epona /etc/systemd/system $ sudo systemctl start "hello@$(systemd-escape /foo-bar/baz).service"
zeal@epona /etc/systemd/system $ sudo systemctl status "hello@$(systemd-escape /foo-bar/baz).service"
● hello@-foo\x2dbar-baz.service - say hello
Loaded: loaded (/etc/systemd/system/hello@.service; static; vendor preset: disabled)
Active: inactive (dead)
Feb 27 15:06:54 epona systemd[1]: Starting say hello...
Feb 27 15:06:54 epona echo[22344]: /foo-bar/baz
Feb 27 15:06:54 epona echo[22345]: -foo\x2dbar-baz
Feb 27 15:06:54 epona systemd[1]: Started say hello.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment