1

When googling around for different oneshot systemd unit files I often stumble upon this kind of file:

[Unit]
Description=/etc/rc.local Compatibility
After=network.target

[Service]
Type=oneshot
ExecStart=-/etc/rc.local
ExecStart=-/pathtoyour/script1
ExecStart=-/pathtoyour/script2
TimeoutSec=0
StandardInput=tty     <======= WHAT'S THIS?
RemainAfterExit=yes   <======= WHAT'S THIS?

[Install]
WantedBy=multi-user.target

See unclear points inline in the example.

erikbstack
  • 12,878
  • 21
  • 81
  • 115

1 Answers1

3
  • StandardInput=tty means that started scripts' standard input is connected to a TTY (by default /dev/console, if no other are specified through "TTYPath=")

  • RemainAfterExit=yes means that service shall be considered active even when all its processes exited.

See here for more information: https://www.freedesktop.org/software/systemd/man/systemd.directives.html

tshepang
  • 12,111
  • 21
  • 91
  • 136
Federico
  • 221
  • 3
  • 11
  • 1
    The question is more about the reasoning behind it, rather than finding the documentation. Why would you want the standardinput of the process to be a tty. I'd say it doesn't need any standardinput. It should just run its commands. And if it's a oneshot it is totally fine if it's gone after being done. Why should it stay active? – erikbstack Jun 09 '17 at 07:25
  • About RemainAfterExit: https://stackoverflow.com/a/38377069/6065692; about StandardInput i think it is just needed to, eg: you have 2 services A and B, where B depends on A. A will create a file, then B will use that file as stdin. And surely other things like these. Instead, StandardOutput is used to redirect your script output to a text file/somewhere else other than stdout/systemd journal. – Federico Jun 09 '17 at 11:19