2017-01-10 4 views
-1

私はすべての起動時に自分の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にテキストをecho'dしている上に、あなたが見ることができるように、ファイル内 期待テキストは一度だけ表示されます。しかし何らかの理由でこのスクリプトは3回実行されます。

/tmp/one.txtにI tail -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を削除する必要がありましたがこの投稿

答えて

0

を読み取るための

感謝。

/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' 

これは、上記で説明した問題を修正しました。

関連する問題