一、查看進程所有線程的方法
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 |