2013年2月9日土曜日

Raspberry Pi:セッション切れ対策だぜぇ~(byobu)


SSHのセッション切れ対策しました♪

SSHでRaspberry Piに接続して色々作業しているが、何かの拍子で突然切れてしまうことがある。
アイドリング中であれば影響は無いのだけれど、
設定ファイルを修正していたりすると、折角いっぱい入力したのに。。。(T_T)となってしまう。
また、再接続しても前のセッションは生きているので、killしたりして精神衛生上も良くない。
何とかならないものかとググっていると、screenやbyobuというソフトを使うとイイらしい。
もっとググると、byobuはscreenのフロントエンドツールで格段に使いやすいとのこと。
これに決~めた!
Byobu community
https://help.ubuntu.com/community/Byobu
を参考にして導入してみた。
1.byobuパッケージのインストール
pi@raspberrypi ~ $ sudo apt-get install byobu Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  python-newt screen tmux
Suggested packages:
  apport lsb-release po-debconf run-one ttf-ubuntu-font-family
  update-notifier-common vim w3m
The following NEW packages will be installed:
  byobu python-newt screen tmux
0 upgraded, 4 newly installed, 0 to remove and 124 not upgraded.
Need to get 463 kB/1,113 kB of archives.
After this operation, 2,129 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main tmux armhf 1.6-2 [224 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main python-newt armhf 0.52.14-10 [103 kB]
Get:3 http://mirrordirector.raspbian.org/raspbian/ wheezy/main byobu all 5.16-1.1 [136 kB]
Fetched 463 kB in 3s (125 kB/s)
Preconfiguring packages ...
Selecting previously unselected package tmux.
(Reading database ... 60212 files and directories currently installed.)
Unpacking tmux (from .../archives/tmux_1.6-2_armhf.deb) ...
Selecting previously unselected package python-newt.
Unpacking python-newt (from .../python-newt_0.52.14-10_armhf.deb) ...
Selecting previously unselected package screen.
Unpacking screen (from .../screen_4.1.0~20120320gitdb59704-7_armhf.deb) ...
Selecting previously unselected package byobu.
Unpacking byobu (from .../byobu_5.16-1.1_all.deb) ...
Processing triggers for man-db ...
Processing triggers for install-info ...
Processing triggers for desktop-file-utils ...
Processing triggers for hicolor-icon-theme ...
Setting up tmux (1.6-2) ...
Setting up python-newt (0.52.14-10) ...
Setting up screen (4.1.0~20120320gitdb59704-7) ...
Setting up byobu (5.16-1.1) ...
2.接続する際に自動的にbyobuを起動する設定
pi@raspberrypi ~ $ byobu-config →メニューで「Byobu currently does not launch at login (toggle on)」を選択
3.ログオフして再接続してみる
pi@raspberrypi ~/.byobu $ ps ax | grep byobu
 4557 pts/1    S+     0:00 grep --color=auto byobu
31557 pts/0    S+     0:00 tmux -2 -f /usr/share/byobu/profiles/tmuxrc
31574 ?        Ss     0:07 tmux -2 -f /usr/share/byobu/profiles/tmuxrc
→byobuが起動している。コンソール画面も華やかになっている(^^)
4.使い方
機能は豊富にあって、はっきり言ってよくわかりません(^_^;)
1)セッション切れ対策としては、自動起動の設定だけでOKOK!
→落ちても、次回接続時に前の状態に復帰します。
2)作業を途中でやめたいときは、「F6」でターミナルを終了します。
→次回接続時には中断した状態に復帰します。
サーバ側ではセッションが継続され続け、接続時にはそのセッションに繋げるようです。
Winのターミナルサービスの感じです。
これで安心(^^)

0 件のコメント:

コメントを投稿