# screen でセッションが途切れてアタッチできない時の対処法 {{tag: linux, screen}} screen を使用中に突然クライアントから通信を切断したりして、セッションは残っているのにアタッチできなくなることがある。その場合は、以下のように対処すると、再び接続できる。 ## 状況 $ screen -ls There is a screen on: 23034.pts-0.sakura123 (Attached) 1 Socket in /var/run/screen/S-foo. つなごとするが、、 $ screen -r There is a screen on: 23034.pts-0.sakura123 (Attached) There is no screen to be resumed. 無理。 ## sshd のプロセスを確認 $ ps aux|grep pts|grep sshd foo 1891 0.0 0.2 9944 1316 ? S 18:42 0:00 sshd: foo@pts/0 foo 8757 0.0 0.2 9812 1320 ? S 20:47 0:00 sshd: foo@pts/9 foo 8877 0.0 0.0 1964 492 pts/9 S+ 20:49 0:00 grep -r sshd grep を実行している pts/9 が現在のセッション。 アタッチできない原因は、pts/0 が残っているから。 ## 復旧 $ kill 1891 $ screen -ls There is a screen on: 23034.pts-0.sakura123 (Detached) 1 Socket in /var/run/screen/S-foo. これでOK $ screen -r