在启动时执行交互式脚本,并显示到默认的tty连接的显示器屏幕
问题描述:
我已经在每次启动时将我的Centos 6配置为自动登录。在启动时执行交互式脚本,并显示到默认的tty连接的显示器屏幕
我修改了/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_profile中运行一个脚本。看下面的内容。
# .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
正如你可以看到上面我已经回显的文本文件/tmp/one.txt,在文件中 预期的文本应该只出现一次。但由于某种原因,这个脚本被执行了3次。
如果我在/tmp/one.txt中出现以下尾巴-f /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文件中删除重生比如$ 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'
解决问题后。 /etc/init/tty.conf看起来像这样。
stop on runlevel [S016]
exec /sbin/mingetty --autologin root $TTY
usage 'tty TTY=/dev/ttyX - where X is console id'
这有修复我解释上面的问题。