我从某个地方了解到,分离的屏幕可能会被
screen -X -S [session # you want to kill] kill
可以从中获取[您要终止的会话#]
screen -ls
但这行不通。有什么问题吗?正确的方法是什么?
我从某个地方了解到,分离的屏幕可能会被
screen -X -S [session # you want to kill] kill
可以从中获取[您要终止的会话#]
screen -ls
但这行不通。有什么问题吗?正确的方法是什么?
当前回答
“kill”只会关闭一个屏幕窗口。要“终止”整个会话,请使用quit。
实例
$ screen -X -S [session # you want to kill] quit
对于死会话,请使用:$屏幕-擦除
其他回答
== ISSUE THIS COMMAND
[xxx@devxxx ~]$ screen -ls
== SCREEN RESPONDS
There are screens on:
23487.pts-0.devxxx (Detached)
26727.pts-0.devxxx (Attached)
2 Sockets in /tmp/uscreens/S-xxx.
== NOW KILL THE ONE YOU DONT WANT
[xxx@devxxx ~]$ screen -X -S 23487.pts-0.devxxx kill
== WANT PROOF?
[xxx@devxxx ~]$ screen -ls
There is a screen on:
26727.pts-0.devxxx (Attached)
1 Socket in /tmp/uscreens/S-xxx.
当给出一些有意义的名称时,更容易终止会话:
//Creation:
screen -S some_name proc
// Kill detached session
screen -S some_name -X quit
将此添加到~/.bashrc:
alias cleanscreen="screen -ls | tail -n +2 | head -n -2 | awk '{print $1}'| xargs -I{} screen -S {} -X quit"
然后使用cleanscreen清理所有屏幕会话。
列表屏幕:
screen -list
输出:
There is a screen on:
23536.pts-0.wdzee (10/04/2012 08:40:45 AM) (Detached)
1 Socket in /var/run/screen/S-root.
终止屏幕会话:
screen -S 23536 -X quit
要终止所有分离的屏幕会话,请在.bash_profile中包含此函数:
killd () {
for session in $(screen -ls | grep -o '[0-9]\{5\}')
do
screen -S "${session}" -X quit;
done
}
要运行它,请调用killd