巧用screen管理Linux远程会话

2015年6月26日13:01:36系统教程评论625

为了管理VPS或者服务器,经常需要ssh或者telent远程登录到Linux服务器,但由于网络不稳定、命令响应时间过长或者不小心关掉窗口,经常会导致远程命令被停止,跑了那么长时间的命令说重来就要重来。怎样才能避再次出现这种尴尬呢?你可以使用screen管理你的Linux远程会话。文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

screen是linux下的一种多重视窗管理程序,可以在多个进程之间多路复用一个物理终端的全屏窗口管理器。用户可以在一个screen会话中创建多个screen子会话,在每一个screen会话(或子会话)中就像操作一个真实的telnet/SSH连接窗口。如果连接非正常中断,重新连接时,可以通过screen恢复原来的会话。文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

安装 screen:文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

Centos、Fedora 系统:文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

yum -y install screen文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

Debian、Ubuntu系统:文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

apt-get -y install screen文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

screen使用介绍:文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

可以通过screen -help查看screen的用法介绍,通过man screen查看screen命令的详细介绍文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

screen命令使用介绍文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

用法举例,创建一个名称为lanmp的会话,文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

screen -S lanmp文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

在此会话中执行命令,如执行wdcp一件安装包。如果此时网络中断或不小心关闭了Putty窗口,只需运行:文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

screen -r lanmp文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

即可恢复原来的会话。昨天安装wdcp时就不小心关掉了putty,还好wdcp一件安装程序创建了lanmp的会话,通过上述指令成功恢复会话并继续执行。文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

 文章源自堕落的鱼-https://www.duoluodeyu.com/1506.html

匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定