一、查看进程所有线程的方法
1、top方法
ps -ef|grep 进程名称或者进程号
top -H -p 进程号
2、ps 方法
ps -T -p 进程号
3、pstree
pstree -Aup -h pid
4、Htop
需要安装Htop
二、杀掉某个进程的线程(未找到相关方法)
1、lsof 方法
lsof -iTCP |grep ip
列出某个ip的tcp链接,查出pid,并杀掉
2、杀死僵尸进程
查看僵死进程:
ps -A -o stat,ppid,pid,cmd | grep -e '^[Zz]'
杀掉
kill -9 pid
自动查杀僵死进程指令:
ps -A -o stat,ppid,pid,cmd | grep -e '^[Zz]' | awk '{print $2}' | xargs kill -9
附录:各种信号及其用途
Signal | Description | Signal number on Linux x86[1] |
---|---|---|
SIGABRT | Process aborted # 进程中止 | 6 |
SIGALRM | Signal raised by alarm # 报警信号 | 14 |
SIGBUS | Bus error: "access to undefined portion of memory object" #总线错误:“访问内存对象的未定义部分” | 7 |
SIGCHLD | Child process terminated, stopped (or continued*) # 子进程终止、停止(或继续*) | 17 |
SIGCONT | Continue if stopped # 如果停止了继续 | 18 |
SIGFPE | Floating point exception: "erroneous arithmetic operation" # 浮点异常:“错误的算术运算” | 8 |
SIGHUP | Hangup # 暂停 | 1 |
SIGILL | Illegal instruction # 非法指令 | 4 |
SIGINT | Interrupt # 中断 | 2 |
SIGKILL | Kill (terminate immediately) # 杀(立即终止) | 9 |
SIGPIPE | Write to pipe with no one reading # 写管道没有人读 | 13 |
SIGQUIT | Quit and dump core # 退出 | 3 |
SIGSEGV | Segmentation violation # 内存段异常 | 11 |
SIGSTOP | Stop executing temporarily # 暂时停止执行 | 19 |
SIGTERM | Termination (request to terminate) # 终止(请求终止) | 15 |
SIGTSTP | Terminal stop signal # 终端停止信号 | 20 |
SIGTTIN | Background process attempting to read from tty ("in") # 试图从tty读取数据的后台进程(“in”) | 21 |
SIGTTOU | Background process attempting to write to tty ("out") # 试图写入tty的后台进程(“out”) | 22 |
SIGUSR1 | User-defined 1 # 用户自定义1 | 10 |
SIGUSR2 | User-defined 2 # 用户自定义2 | 12 |
SIGPOLL | Pollable event # 可投票的事件 | 29 |
SIGPROF | Profiling timer expired # 仿形计时器过期 | 27 |
SIGSYS | Bad syscall # 糟糕的系统调用 | 31 |
SIGTRAP | Trace/breakpoint trap # 跟踪/断点陷阱 | 5 |
SIGURG | Urgent data available on socket # 紧急数据在插座上可用 | 23 |
SIGVTALRM | Signal raised by timer counting virtual time: "virtual timer expired" # 计时器计数虚拟时间引起的信号:“虚拟计时器过期” | 26 |
SIGXCPU | CPU time limit exceeded # 中央处理器时限超过 | 24 |
SIGXFSZ | File size limit exceeded # 超过档案大小限制 | 25 |