[英]How to close other active session on putty running on another computer?
我正在尝试关闭在其他计算机上运行的腻子会话。
You kill
the process ID of the user's login session: 您
kill
用户的登录会话的进程ID:
kill -9 12345
Try running the w
command and looking at the output. 尝试运行
w
命令并查看输出。 Something like: 就像是:
w | grep ssh
will show all users connected via ssh
. 将显示所有通过
ssh
连接的用户。 More scripting and automation is possible to help you narrow down the process ID of the login session: 更多的脚本和自动化功能可以帮助您缩小登录会话的进程ID:
pgrep -u w | grep ssh| awk '{print $1}'
pgrep -u
w | grep ssh| awk '{print $1}'
w | grep ssh| awk '{print $1}'
w | grep ssh| awk '{print $1}'
ssh w | grep ssh| awk '{print $1}'
ssh
will give you a list of numbers that are the PID
s of the login session. 将为您提供一个数字列表,这些数字是登录会话的
PID
。 You can then use ps
to verify that this is the session you want to kill
. 然后,您可以使用
ps
验证这是您要kill
的会话。 See the kill(1)
, ps
, and pgrep
manual pages. 请参见
kill(1)
, ps
和pgrep
手册页。
You can get fancy and make a script or shell alias to print the users and their ssh sessions (NB: quick hack for illustration, not portable): 您可以看中并创建脚本或shell别名来打印用户及其ssh会话(注意:用于说明的快速hack,不可移植):
for u in `w| grep ssh|awk '{print $1}'`
do
echo -e "\n"$u
pgrep -x -l -u $u ssh
done
... and other variation on this theme. ...以及与此主题相关的其他变化。 If you are killing sessions this way oftne it's a good idea to have a script or tool that helps you identify the correct session before your
kill -9
it - especially on a busy shell login host. 如果您以这种方式终止会话,最好有一个脚本或工具来帮助您在终止
kill -9
之前识别正确的会话,尤其是在繁忙的Shell登录主机上。 Even more useful are tools that are cross platform and/or POSIX
-ish ( w
who
ps
etc. vary slightly in their output formats). 更有用的是跨平台和/或工具
POSIX
-ish( w
who
ps
等在他们的输出格式略有不同)。 That kind of tool can be written in perl
, ruby
or very careful sh
and awk
. 这种工具可以用
perl
, ruby
或非常小心的sh
和awk
编写。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.