如何列出正在运行的屏幕会话? [英] How to list running screen sessions?
问题描述
我有一堆服务器,我在这些服务器上使用screen
进行实验.步骤如下:
I have a bunch of servers, on which I run experiments using screen
. The procedure is the following :
-
ssh
到服务器XXX - 启动
screen
- 在几个标签中开始实验
- 分离
screen
- 断开与服务器的连接
ssh
to server XXX- launch
screen
- start experiments in a few tabs
- detach
screen
- disconnect from the server
在运行实验的同时,我可以通过ssh
访问所有服务器并列出正在运行的进程(使用top
或ps
)来轻松找到它们在哪些服务器上.
While the experiments are running, I can easily find on which servers they are by ssh
ing to all servers and listing my running processes (using top
or ps
).
但是,一旦实验完成,我如何才能找到在哪个服务器上打开了屏幕会话(以便可以查看输出,重新启动它们,等等)?
However, once the experiments are finished, how could I find on which servers I have a screen session opened (so that I can have a look at the output, relaunch them, etc.) ?
PS:我的实验也将其输出也打印到文件中……但这不是我要问的重点.
PS: my experiments do print their output to files, too... but this is not the point of my question.
推荐答案
要列出某个用户的所有屏幕会话,请以该用户身份运行以下命令:
To list all of the screen sessions for a user, run the following command as that user:
screen -ls
要查看特定计算机上的所有屏幕会话,您可以执行以下操作:
To see all screen sessions on a specific machine you can do:
ls -laR /var/run/screen/
我在我的机器上得到了
gentle ~ # ls -laR /var/run/screen/
/var/run/screen/:
total 1
drwxrwxr-x 4 root utmp 96 Mar 1 2005 .
drwxr-xr-x 10 root root 840 Feb 1 03:10 ..
drwx------ 2 josh users 88 Jan 13 11:33 S-josh
drwx------ 2 root root 48 Feb 11 10:50 S-root
/var/run/screen/S-josh:
total 0
drwx------ 2 josh users 88 Jan 13 11:33 .
drwxrwxr-x 4 root utmp 96 Mar 1 2005 ..
prwx------ 1 josh users 0 Feb 11 10:41 12931.pts-0.gentle
/var/run/screen/S-root:
total 0
drwx------ 2 root root 48 Feb 11 10:50 .
drwxrwxr-x 4 root utmp 96 Mar 1 2005 ..
这是Unixy对Unix套接字的一种非常出色的使用,它封装在文件系统权限中以处理安全性,状态和流.
This is a rather brilliantly Unixy use of Unix Sockets wrapped in filesystem permissions to handle security, state, and streams.
这篇关于如何列出正在运行的屏幕会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!