如何杀死Unix中的tty [英] how to kill the tty in unix

查看:121
本文介绍了如何杀死Unix中的tty的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是finger命令的结果(我(Vidya)登录时今天(星期一))

This is the result of the finger command (Today(Monday) when I (Vidya) logged in)

sekic1083 [6:14am] [/home/vidya] -> finger
Name        Tty       Idle   Login Time    Where
Felix   pts/0        -       Thu 10:06  sekic2594.rnd.ki.sw.
john        pts/1       2d       Fri 15:43
john        *pts/2      2d       Fri 15:43
john      *pts/3       4     Fri 15:44
john      *pts/7       -         Thu 16:25
Vidya      pts/0       -         Mon 06:14
Vidya     *pts/5       -         Mon 06:14
Vidya     *pts/6       -         Tue 10:13
Vidya     *pts/9       -         Wed 05:39
Vidya     *pts/10      -         Wed 10:23

Tty pts/0 and pts/5列下的是当前活动端子.

Under column the Tty pts/0 and pts/5 are the current active terminals.

除了这两个pts/6pts/9pts/10之外,我上周也都登录了.但是它们的空闲时间显示为-"(不是空闲).

Apart from those two pts/6, pts/9 and pts/10 are also present and I had logged into these last week. But the idle time for them is showing as "-" (not idle).

如何杀死这6,9和10个终端?

How can I kill these 6,9 and 10 terminals?

推荐答案

您可以运行:

ps -ft pts/6 -t pts/9 -t pts/10

这将产生类似于以下内容的输出:

This would produce an output similar to:

UID        PID  PPID  C STIME TTY          TIME CMD
Vidya      772  2701  0 15:26 pts/6    00:00:00 bash
Vidya      773  2701  0 16:26 pts/9    00:00:00 bash
Vidya      774  2701  0 17:26 pts/10   00:00:00 bash

从结果中获取PID.

使用PID终止进程:

kill <PID1> <PID2> <PID3> ...

对于以上示例:

kill 772 773 774

如果进程没有正常终止,那么作为最后一个选择,您可以通过发送SIGKILL

If the process doesn't gracefully terminate, just as a last option you can forcefully kill by sending a SIGKILL

kill -9 <PID>

这篇关于如何杀死Unix中的tty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆