Akemi

linux screen与tmux

2024/05/06

如果出现无法载图的情况,请检查与github的连通性

使用ssh运行一个程序的时候,这个程序是建立在sshd subprocess的bash上的,如果ssh断开,程序建立的bash也会关闭。使用linux screen与tmux就可以解决这个问题

screen

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
yum -y intsall epel-release 
yum -y install screen #安装screen#
screen -S name 创建会话
screen -ls 查看目前已有的screen
screen -r name恢复之前的session
screen -x 可以让多人共享一个session

例:
screen -S wangsheng
while true; do date >> /tmp/time.txt; sleep 1; done
输入ctrl+a 松手d,进行分离
screen -ls

#恢复
screen -r 3720.wangsheng

tmux

1
2
3
4
5
6
7
8
9
10
11
能达到screen效果,而且更华丽
yum -y install tmux
tmux -L wangsheng #创建会话,保存为文件
tmux new -s wangsheng #创建可恢复的会话
ctrl+b 松手d 脱离

tmux ls #列表
tmux attach -t wangsheng # 恢复会话
ctrl+b 松手“ 上下分离
ctrl+b 松手% 左右分离
ctrl+b 松手↑↓←→转换区域

tmux ls显示failed to conntect server解决方法

查看进程是否存在创建的tmux

lsof -p 3248

可以看到进程和socket都存在

kill -s USR1 3248 #重新发送信号#

参考资料:
linux - Why am I getting a “failed to connect to server” message from tmux when I try to list sessions? - Stack Overflow

原文作者:王盛

原文链接:https://akemi.zj.cn/2024/05/06/tmux/

发表日期:May 6th 2024, 9:57:14 pm

更新日期:February 20th 2025, 6:37:27 pm

版权声明:本文采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可

CATALOG
  1. 1. screen
  2. 2. tmux
    1. 2.1. tmux ls显示failed to conntect server解决方法