linux-screen-command命令及示例

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

本文包含两部分。

第一部分虽然是整理来的英文资料,但平时搜索不容易搜索到,所以还是比较有价值的,是关于多路利用终端软件详解和比较的/multiplexers,然后把自己不关心的tmux部分删除后,只留下screen的部分。

第二部分针对原文命令行参数部分的不足增加了完整的help,并增加了一个sipP测试的例子。

本人其实只关心原文的screen command那一列,因为从命令行help无法获取这一部分信息,而我一起在苦苦查找这部分资料,它对以编程的方式控制screen是非常重要的参考,使在无人值守的情况下(如定时或在系统崩溃重新启动后)自动创建一个有多window的screen并启动若干后台测试成为可能。

1.Terminology

server | client | session | window | region | pane

how ssh works:

When a user logs in to a remote host using ssh, the ssh process contacts an sshd process listening on TCP port 22. The sshd process opens up a new TCP port and forks off a copy of itself for communicating with the ssh process. The new port and child process are for the exclusive use of the connection being established.

The child sshd process authenticates the ssh process, and if it passes it creates a pseudo-terminal. It then forks the remote user's shell which becomes the controlling process for the pseudo-terminal.

If the network connection is closed, either explicitly by the ssh process or because of a loss of network connectivity, the child sshd process closes the pseudo-terminal, and this in turn causes the shell to exit.

the SIGHUP problem:

If the shell had any process groups running when it exits, they are sent a SIGHUP signal followed by a SIGCONT signal. By default processes exit when they receive SIGHUP. This makes it challenging to run long-running jobs on a remote host when the network connection is unreliable.

A simple solution to the SIGHUP problem is to run each job with nohup. Optionally, shells such as bash and zsh have a disown built-in which can be used on a process that is already running, should the user have neglected to run it with nohup.

The fish shell when invoking a process in the background with & sets the signal handling state of the process to ignore SIGHUP. It will do the same if the process is suspended with ^Z and then put in the background with bg.

Multiplexers offer a solution which protects the shell instead of the job. The user doesn't need to remember to run each job with nohup. As an added benefit any state kept by the shell is preserved.

server:

The multiplexer server creates pseudo-terminals which are used for running and interacting with programs.

Screen and Tmux servers can create multiple pseudo-terminals. The controlling process for each pseudo-terminal is the user's shell.

client:

To see the output of a shell the user must connect to the multiplexer server with a multiplexer client process.

If the multiplexer is being run on a remote machine and the user's connection is lost, the server and its terminals and controlling processes persist, but the client process exits.

When multiple client processes connect to the same server they see the same output. This is a way to share a display across computers.

session:

Multiplexers support multiple sessions. Each multiplexer session has its own set of terminals and controlling processes which it is running. The client must choose a session to attach to, and will only be able to see the output of the controlling processes in that session. Sessions can be given names to make it easy for the client to choose the correct session.

Screen launches a separate server process for each session. Screen servers and clients communicate via named pipes.

Tmux by default will only run one server process per user, and this server process can have multiple sessions. A Tmux client and the server communicate via a Unix domain socket in the /tmp directory. The -L option can be used to specify a different socket; a new server is created for each socket.

window:

相关文档
最新文档