Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 启动时执行交互式脚本并显示为默认tty连接的监视器屏幕_Linux_Bash_Startup_Tty - Fatal编程技术网

Linux 启动时执行交互式脚本并显示为默认tty连接的监视器屏幕

Linux 启动时执行交互式脚本并显示为默认tty连接的监视器屏幕,linux,bash,startup,tty,Linux,Bash,Startup,Tty,我已将Centos 6配置为在每次启动时自动登录 我已经修改了/etc/init/tty.conf来实现这一点,效果很好 /etc/init/tty.conf的内容 stop on runlevel [S016] respawn instance $TTY #exec /sbin/mingetty $TTY exec /sbin/mingetty --autologin root $TTY usage 'tty TTY=/dev/ttyX - where X is console id'

我已将Centos 6配置为在每次启动时自动登录

我已经修改了/etc/init/tty.conf来实现这一点,效果很好

/etc/init/tty.conf的内容

stop on runlevel [S016]

respawn
instance $TTY
#exec /sbin/mingetty $TTY
exec /sbin/mingetty --autologin root $TTY
usage 'tty TTY=/dev/ttyX  - where X is console id'
然后,我将~/.bash_配置文件配置为运行脚本。请参阅下面的内容

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH


echo "This is one time" >/tmp/one.txt
正如您在上面看到的,我将echo'd文本添加到文件/tmp/one.txt中, 文件中的预期文本应仅显示一次。但由于某些原因,此脚本执行了3次

如果I tail-f/tmp/one.txt,则在/tmp/one.txt中会出现以下内容。它显示脚本执行了3次

tail -f /netboot/tmp/one.txt
This is one time
tail: /netboot/tmp/one.txt: file truncated
This is one time
tail: /netboot/tmp/one.txt: file truncated
This is one time
tail: /netboot/tmp/one.txt: file truncated
This is one time
我能做些什么来防止它执行多次,我只想让它运行一次,就这样


感谢您阅读本文

我不得不从/etc/init/TTY.conf文件中删除respawn instance$TTY

在修复之前,/etc/init/tty.conf如下所示

stop on runlevel [S016]

respawn
instance $TTY
#exec /sbin/mingetty $TTY
exec /sbin/mingetty --autologin root $TTY
usage 'tty TTY=/dev/ttyX  - where X is console id'
stop on runlevel [S016]


exec /sbin/mingetty --autologin root $TTY
usage 'tty TTY=/dev/ttyX  - where X is console id'
解决问题后/etc/init/tty.conf如下所示

stop on runlevel [S016]

respawn
instance $TTY
#exec /sbin/mingetty $TTY
exec /sbin/mingetty --autologin root $TTY
usage 'tty TTY=/dev/ttyX  - where X is console id'
stop on runlevel [S016]


exec /sbin/mingetty --autologin root $TTY
usage 'tty TTY=/dev/ttyX  - where X is console id'
这解决了我上面解释的问题