Linux – How to run /etc/init/ttys0.conf automatically at startup

bootlinuxUbuntu

I have a script at /etc/init/ttyS0.conf. I'm configuring a KVM guest for Serial Console access so even if the network interface is broken, I can still access it via the serial connection.

I can start the ttyS0 by running sudo start ttyS0 and it works just fine until I reboot. Upon rebooting the system, the ttyS0 isn't running anymore.

How can I get this script to to tun automatically at startup?

Thanks


Here's what my script looks like:

# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]

respawn
exec /sbin/getty -L 115200 ttyS0 xterm

Best Answer

From here

respawn
console none

start on (local-filesystems)
stop on [!12345]

script

exec start ttyS0
end script

Should work i suspect. else, replace start tty0 with a script that starts what you want to start