个人感觉tmux比nohup好用
在nohup使用中,老是出现:
nohup the input device is not a TTY
后面就索性就下载量tmux
安装tmux
# Ubuntu 或 Debian $ sudo apt-get install tmux # CentOS 或 Fedora $ sudo yum install tmux # Mac $ brew install tmux
新建会话
使用编号区分会话,不太直观,更好的方法是为会话起名。
$ tmux new -s
分离会话
就是把当前的会话后台挂起
在 Tmux 窗口中,按下Ctrl+b d或者输入tmux detach命令,就会将当前会话与窗口分离。
上面命令执行后,就会退出当前 Tmux 窗口,但是会话和里面的进程仍然在后台运行。
查看所有会话
$ tmux ls # or $ tmux list-session
返回会话
# 使用会话编号 $ tmux attach -t 0 # 使用会话名称 $ tmux attach -t
结束会话
# 使用会话编号 $ tmux kill-session -t 0 # 使用会话名称 $ tmux kill-session -t
重命名会话
tmux rename-session -t 0
上面命令将0号会话重命名
最简操作流程
1.新建会话tmux new -s my_session。
2.在 Tmux 窗口运行所需的程序。
3.按下快捷键Ctrl+b d将会话分离。
4.下次使用时,重新连接到会话tmux attach-session -t my_session。
会话快捷键
Ctrl+b d:分离当前会话。
Ctrl+b s:列出所有会话。
Ctrl+b $:重命名当前会话。



