如何在 CentOs 中使用命令行杀死所有打开的终端
How to kill all open terminals using command lines in CentOs
我正在使用 putty 连接到 Centos,有时它会断开连接,而 centos 上打开的终端保持打开状态,有没有办法通过命令行 close/kill 所有打开的终端?
如果您使用的是linux,那么只需找出 putty 的进程 ID
使用ps -a
获取进程的PID然后使用kill PID
在 Windows 上:
Open the command prompt as the current user or as Administrator.
Type tasklist to see the list of running processes and their PIDs. ...
To kill a process by its PID, type the command: taskkill /F /PID pid_number.
To kill a process by its name, type the command taskkill /IM "process name" /F.
识别进程
ps-ef | grep -E 'ssh.*pts' | grep -v grep |awk -F" " '{print $2}'
上面的脚本会给你机器上那些 ssh pst 连接的 PID;然后正如 Vikas 所说,您可以 kill 这些进程,请记住使用 kill 命令注意。
注意:您可以使用 last 命令,您可以在其中查看计算机上 current/olders 会话的列表。
终止进程
kill -9 PID1 PID2 PID3
使用命令终止旧登录:
pkill -o -u $USER sshd
您可以使用 'screen' 程序从连接丢失的地方重新连接。
如果你想杀死除当前终端之外的所有打开的终端,你可以使用
kill $(pgrep bash)
pgrep bash
列出所有活动终端的pid
如果终端死机,可以使用
kill -9 $(pgrep bash)
“-9”用于向进程发送 SIGKILL 信号
我正在使用 putty 连接到 Centos,有时它会断开连接,而 centos 上打开的终端保持打开状态,有没有办法通过命令行 close/kill 所有打开的终端?
如果您使用的是linux,那么只需找出 putty 的进程 ID
使用ps -a
获取进程的PID然后使用kill PID
在 Windows 上:
Open the command prompt as the current user or as Administrator.
Type tasklist to see the list of running processes and their PIDs. ...
To kill a process by its PID, type the command: taskkill /F /PID pid_number.
To kill a process by its name, type the command taskkill /IM "process name" /F.
识别进程
ps-ef | grep -E 'ssh.*pts' | grep -v grep |awk -F" " '{print $2}'
上面的脚本会给你机器上那些 ssh pst 连接的 PID;然后正如 Vikas 所说,您可以 kill 这些进程,请记住使用 kill 命令注意。
注意:您可以使用 last 命令,您可以在其中查看计算机上 current/olders 会话的列表。
终止进程
kill -9 PID1 PID2 PID3
使用命令终止旧登录:
pkill -o -u $USER sshd
您可以使用 'screen' 程序从连接丢失的地方重新连接。
如果你想杀死除当前终端之外的所有打开的终端,你可以使用
kill $(pgrep bash)
pgrep bash
列出所有活动终端的pid
如果终端死机,可以使用
kill -9 $(pgrep bash)
“-9”用于向进程发送 SIGKILL 信号