在公司使用ssh连接服务器训练,ssh断线后就不能继续训练!
那就要一会儿动一下terminal,这的多难受啊!!
开始使用nohup使得ssh连接断线后训练仍可继续
但是没有输出就很难受!
然后查看有screen和tmux两种方法,可以继续训练,随时想回来看回来看。
其中大家都说tmux可以分屏很高级,那就直接来好的试试。
下载
我们肯定没有公司服务器权限,网上一大堆直接 *** install tmux的直接忽略,看过几个无root权限下载的教程,
第一个方法:
我推荐这个 linux 无root权限安装tmux(脚本自动安装)_huang007guo的专栏-CSDN博客_无sudo权限安装tmux
1)创建一个sh文件: touch tmux_install.sh
2) 打开sh文件:vim tmux_install.sh
3) 将以下代码拷到刚创建的sh文件
4)运行sh文件:bash tmux_install.sh
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
# create our directories
mkdir -p $HOME/local $HOME/tmux_tmp
cd $HOME/tmux_tmp
# download source files for tmux, libevent, and ncurses
wget -O tmux-${TMUX_VERSION}.tar.gz https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz
#http://sourceforge.net/projects/tmux/files/tmux/tmux-${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz/download
wget https://github.com/downloads/libevent/libevent/libevent-2.0.19-stable.tar.gz
wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.1.tar.gz
# extract files, configure, and compile
############
# libevent #
############
tar xvzf libevent-2.0.19-stable.tar.gz
cd libevent-2.0.19-stable
./configure --prefix=$HOME/local --disable-shared
make
make install
cd ..
############
# ncurses #
############
tar xvzf ncurses-6.1.tar.gz
cd ncurses-6.1
./configure --prefix=$HOME/local
make
make install
cd ..
############
# tmux #
############
tar xvzf tmux-${TMUX_VERSION}.tar.gz
cd tmux-${TMUX_VERSION}
./configure CFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-L$HOME/local/lib -L$HOME/local/include/ncurses -L$HOME/local/include" CPPFLAGS="-I$HOME/local/include -I$HOME/local/include/ncurses" LDFLAGS="-static -L$HOME/local/include -L$HOME/local/include/ncurses -L$HOME/local/lib"
make
cp tmux $HOME/local/bin
cd ..
# cleanup
rm -rf $HOME/tmux_tmp
#这句提醒将$HOME/local/bin加入环境变量
echo "$HOME/local/bin/tmux is now available. You can optionally add $HOME/local/bin to your PATH. 1\ Open "~/.bashrc" and add line: export PATH="~/local/bin:$PATH" ." 2\ Use command: source ~/.bashrc
整洁清晰无毛病。
然后就可以安装了,最后会报编译ncurses的奇奇怪怪错误,但直接敲命令
tmux
依旧是可以打开的,而且可以正常使用,所以我没有管这个错误。
第二个方法:
如果上面有问题,我在推荐一个同学整理的很好的
Tmux安装教程(非root用户,ubuntu)_baidu_32335419的博客-CSDN博客_tmux 非root
其中第一步是下载3个文件到本地,然后再上传到服务器 /home/XXX/ 路径下。
之后就用bash自己动就好了。
使用
使用的话我再次推荐一个:
这个内容太多我就不抄了。
试试吧
做点其他的:
添加tmux的鼠标功能,可以实现调节窗口大小等功能