如何从列表中重新附加和关闭多个屏幕会话
我是 Ubuntu 9.04 用户。给定一个屏幕会话列表,如下所示:
9076.pts-30.moe (09/27/2009 11:30:08 PM) (Attached)
8778.pts-24.moe (09/27/2009 11:29:46 PM) (Detached)
8674.pts-0.moe (09/27/2009 11:29:25 PM) (Attached)
22649.pts-28.moe (09/27/2009 11:51:46 AM) (Detached)
22543.pts-24.moe (09/27/2009 11:50:56 AM) (Detached)
22228.pts-16.moe (09/27/2009 11:49:59 AM) (Detached)
我如何根据时间标准关闭多个屏幕?例如,所有屏幕在中午 12:00 之前启动。我通常会输入:
screen -dr 22649.pts-28.moe
exit
...
并手动关闭每一个,但这很乏味。提前致谢。
I am an Ubuntu 9.04 user. Given a list of screen sessions such as the following:
9076.pts-30.moe (09/27/2009 11:30:08 PM) (Attached)
8778.pts-24.moe (09/27/2009 11:29:46 PM) (Detached)
8674.pts-0.moe (09/27/2009 11:29:25 PM) (Attached)
22649.pts-28.moe (09/27/2009 11:51:46 AM) (Detached)
22543.pts-24.moe (09/27/2009 11:50:56 AM) (Detached)
22228.pts-16.moe (09/27/2009 11:49:59 AM) (Detached)
How would I close out multiple screens based on a time criterion? For instance, all screens initiated before 12:00 PM. I normally would type:
screen -dr 22649.pts-28.moe
exit
...
and close each one out manually, but this is tedious. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
下面是我杀死所有分离屏幕的方法:
如果你想强行杀死所有屏幕,只需将上面的
grep Detached
更改为grep tached
即可。至少对我来说一直有效!对于时间标准,您可以从以下内容开始:
这将打印类似以下内容的内容:
其中第一组是时间戳并用逗号分隔,是 PID.name。
因此您可以再次使用 /pipe 到
awk
(或awk -F"," '{print $1}'
来精确提取时间戳,在括号中)来解析括号内的时间..记住,screen -ls
总是最后列出最早的屏幕!我还没有弄清楚如何自己进行时间标准过滤,如果可以的话,我将来会编辑它..祝你好运,伙计!
Here's how I kill all detached screens:
if you want to forcibly kill all screens, just change
grep Detached
above togrep tached
. Works for me all the tine, at the very least!for time criterion, you can start with this:
this prints something like:
where the first group is the timestamp and separated by a comma, is the PID.name.
so you could use/pipe to
awk
(orawk -F"," '{print $1}'
to exactly extract the timestamps only, in parentheses) again to parse the time inside the parentheses.. remember,screen -ls
always lists the earliest screen last!I have not figured out how to do time criterion filtering myself, i'll edit this in the future if i could.. good luck buddy!
您可以使用 -X 参数将命令发送到屏幕。因此,您可以通过说“screen -S 22649.pts-28.moe -X quit”从命令行关闭屏幕。
要按时间选择屏幕,我想您必须运行脚本来比较时间。
就我个人而言,我会在 python 中使用 os.popen() 和 time.strptime() 。
You can send commands to a screen using the -X parameter. So you can close a screen from the command line by saying "screen -S 22649.pts-28.moe -X quit".
To select the screens by time, I guess you have to run a script to compare the times.
Personally, I would use os.popen() and time.strptime() in python.
点之前的数字(示例中的
22649
)是屏幕进程的 PID。只需杀死它即可(kill 22649
)The number before the dot (
22649
in your example) is the PID of the screen process. Just kill it (kill 22649
)