如何在启动时重启进程

如何在启动时重启进程

在 Slackware 中,我只需在 initab 中更改一行,即可在启动时自动重生并在另一个控制台中运行我的程序,如何在 Ubuntu 中实现这一点?似乎需要一个 phd 在 /etc/init/myprogram 中编写一个 upstart 文件

c2:1235:respawn:/home/gerrie/myprogram 1<&2 1>/dev/tty2 <dev/tty2

提前致谢

答案1

只需调整其中一项现有工作:

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

start on stopped rc RUNLEVEL=[2345] and (
            not-container or
            container CONTAINER=lxc or
            container CONTAINER=lxc-libvirt)

stop on runlevel [!2345]

respawn
exec /sbin/getty -8 38400 tty1

你可能想让它看起来像这样:

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

start on stopped rc RUNLEVEL=[2345] and (
            not-container or
            container CONTAINER=lxc or
            container CONTAINER=lxc-libvirt)

stop on runlevel [!2345]

respawn
exec /sbin/getty -8 38400 -l /home/gerrie/myprogram tty2

相关内容