[20230323]ps命令檢視thread.txt
[20230323]ps命令檢視thread.txt
--//前一段時間遇到的問題,ps -fp <pid> ,沒有查詢到對應程式,當時有點蒙.
--//現在想想可能對應的是執行緒,不能透過這樣的方式查詢.應該加入-L引數.
--//看了一些檔案順便學習相關內容.
$ ps -o nlwp,pid,lwp,user,args -u grid | awk '$1>1 { print $0}'
NLWP PID LWP USER COMMAND
28 8870 8870 grid /u01/app/11.2.0/grid/bin/oraagent.bin
9 11035 11035 grid /u01/app/11.2.0/grid/bin/gipcd.bin
4 11037 11037 grid /u01/app/11.2.0/grid/bin/mdnsd.bin
18 11163 11163 grid /u01/app/11.2.0/grid/bin/ocssd.bin
17 11949 11949 grid /u01/app/11.2.0/grid/bin/evmd.bin
6 12285 12285 grid /u01/app/11.2.0/grid/bin/gpnpd.bin
54 14183 14183 grid /u01/app/11.2.0/grid/jdk/bin/java -server -Xcheck:jni -Xms128M -Xmx384M
-Djava.awt.headless=true -Ddisable.checkForUpdate=true -Dstdstream.filesize=100 -Dstdstream.filenumber=10
-DTRACING.ENABLED=false -Doracle.wlm.dbwlmlogger.logging.level=INFO -Dport.rmi=23792 -jar
/u01/app/11.2.0/grid/oc4j/j2ee/home/oc4j.jar -config /u01/app/11.2.0/grid/oc4j/j2ee/home/OC4J_DBWLM_config/server.xml
-out /u01/app/11.2.0/grid/oc4j/j2ee/home/log/oc4j.out -err /u01/app/11.2.0/grid/oc4j/j2ee/home/log/oc4j.err
23 15261 15261 grid /u01/app/11.2.0/grid/bin/oraagent.bin
3 24695 24695 grid /u01/app/11.2.0/grid/bin/tnslsnr dbrayw -inherit
16 30995 30995 grid /u01/app/11.2.0/grid/opmn/bin/ons -d
3 31146 31146 grid /u01/app/11.2.0/grid/bin/tnslsnr LISTENER_SCAN2 -inherit
3 31152 31152 grid /u01/app/11.2.0/grid/bin/tnslsnr LISTENER_SCAN3 -inherit
3 31268 31268 grid /u01/app/11.2.0/grid/bin/tnslsnr LISTENER -inherit
--//nlwp等於對應執行緒的數量.
$ ps -o nlwp,pid,lwp,user,args -u oracle | awk '$1>1 { print $0}'
NLWP PID LWP USER COMMAND
16 15415 15415 oracle /u01/app/11.2.0/grid/bin/oraagent.bin
--//奇怪怎麼兩個使用者oracle,grid下都有這個程式執行.
--//在測試環境檢視:
$ ps -o nlwp,pid,lwp,args -e | awk '$1>1 { print $0}'
NLWP PID LWP COMMAND
2 4049 4049 auditd
2 4051 4051 /sbin/audispd
5 4384 4384 automount --pid-file /var/run/autofs.pid
6 9290 9290 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
3 44997 44997 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
--//如果要想顯示全部執行緒,可以加入-L引數加上grep過濾就可以得到程式號.
$ ps -eLf | grep "tnslsn[r]"
oracle 44997 1 44997 0 3 Mar20 ? 00:10:23 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44998 0 3 Mar20 ? 00:00:05 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44999 0 3 Mar20 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
--//第5列3表示執行緒數量.
$ ps -eLf | grep "rsyslog[d]"
root 9290 1 9290 0 6 2021 ? 00:00:00 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
root 9290 1 33554 0 6 Mar11 ? 00:00:00 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
root 9290 1 33555 0 6 Mar11 ? 00:00:01 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
root 9290 1 33556 0 6 Mar11 ? 00:00:23 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
root 9290 1 33557 0 6 Mar11 ? 00:00:00 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
root 9290 1 3272 0 6 10:35 ? 00:00:00 /sbin/rsyslogd -i /var/run/rsyslogd.pid -c3 -x
--//還可以執行如下:
$ ps -Lfp 44997
UID PID PPID LWP C NLWP STIME TTY TIME CMD
oracle 44997 1 44997 0 3 Mar20 ? 00:10:24 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44998 0 3 Mar20 ? 00:00:12 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44999 0 3 Mar20 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
--//透過pstack觀察.
$ pstack 44997
Thread 3 (Thread 0x7f23ea92c940 (LWP 44998)):
#0 0x000000379909a221 in nanosleep () from /lib64/libc.so.6
#1 0x000000379909a044 in sleep () from /lib64/libc.so.6
#2 0x00007f23ebe1398a in ons_receivethread () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libons.so
#3 0x000000379a00683d in start_thread () from /lib64/libpthread.so.0
#4 0x00000037990d503d in clone () from /lib64/libc.so.6
Thread 2 (Thread 0x7f23ea8eb940 (LWP 44999)):
#0 0x000000379a00b019 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007f23ebe13289 in ons_recvthread_getsocket () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libons.so
#2 0x00007f23ebe14ef2 in ons_sendthread () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libons.so
#3 0x000000379a00683d in start_thread () from /lib64/libpthread.so.0
#4 0x00000037990d503d in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x7f23ebc096e0 (LWP 44997)):
#0 0x00000037990cc116 in poll () from /lib64/libc.so.6
#1 0x00007f23ee3a62bd in ntevpque () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libclntsh.so.11.1
#2 0x00007f23ee3a5f20 in ntevque () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libclntsh.so.11.1
#3 0x00007f23ee3a1d71 in nsevwait () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libclntsh.so.11.1
#4 0x000000000040842e in nsglma ()
#5 0x00000000004063cb in main ()
--//如果檢視執行緒執行如下.
$ pstack 44998
Thread 1 (process 44998):
#0 0x000000379909a221 in nanosleep () from /lib64/libc.so.6
#1 0x000000379909a044 in sleep () from /lib64/libc.so.6
#2 0x00007f23ebe1398a in ons_receivethread () from /u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libons.so
#3 0x000000379a00683d in start_thread () from /lib64/libpthread.so.0
#4 0x00000037990d503d in clone () from /lib64/libc.so.6
--//缺點不知道程式號.
--//另外執行緒有1個特點,如果你kill其中1個執行緒,整個程式也會kill掉,測試看看.
$ kill -URG 44998
$ ps -Lfp 44997
UID PID PPID LWP C NLWP STIME TTY TIME CMD
oracle 44997 1 44997 0 3 Mar20 ? 00:10:24 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44998 0 3 Mar20 ? 00:00:12 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 44997 1 44999 0 3 Mar20 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
$ kill -9 44998
$ ps -Lfp 4499
UID PID PPID LWP C NLWP STIME TTY TIME CMD
$ ps -eLf | grep "tnslsn[r]"
--//沒有任何輸出.
$ lsnrctl start
....
$ ps -eLf | grep "tnslsn[r]"
oracle 34299 1 34299 0 3 10:07 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 34299 1 34300 0 3 10:07 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 34299 1 34301 0 3 10:07 ? 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr LISTENER -inherit
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2941980/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Linux ps命令詳解,Linux檢視程序。Linux
- Linux中常用來檢視程式的命令PSLinux
- Linux程式之如何檢視程式詳情?(ps命令)Linux
- Linux檢視程序命令ps和top示例詳解Linux
- 每天一個Linux命令之ps-檢視系統程式資訊Linux
- [20230323]sqlplus #.txtSQL
- ps命令
- Linux下使用ps命令來檢視oracle資料庫相關程式的操作步驟LinuxOracle資料庫
- Linux 系統檢視命令Linux
- linux檢視裝置命令Linux
- 磁碟陣列檢視命令 RAID陣列AI
- docker檢視容器日誌命令Docker
- 檢視程序的啟動命令
- LINUX 檢視硬體配置命令Linux
- Linux檢視環境變數當前資訊和檢視命令Linux變數
- GDB檢視記憶體(x 命令)記憶體
- 檢視hp小型機命令集
- 檢視系統型別的命令型別
- curl命令檢視響應時間
- navicat檢視mysql安裝位置命令MySql
- Oracle常用檢視錶結構命令Oracle
- Linux檢視系統版本命令Linux
- Linux 檢視系統檔案命令Linux
- Cmd命令 檢視埠被佔用
- CentOS7檢視開放埠命令、檢視埠占用情況和開啟埠命令、殺掉程式等命令教程。CentOS
- 程式命令ps/top/kill
- Oracle檢視執行計劃的命令Oracle
- Linux檢視檔案的命令有哪些?Linux
- 在Linux命令列檢視影像的方法Linux命令列
- Linux 檢視日誌的命令彙總Linux
- Linux 檢視檔案內容——bat 命令LinuxBAT
- 【AIX-PS】AIX系統ps命令詳解AI
- 檢視ip地址的cmd命令 cmd查詢ip地址命令
- linux命令檢視記憶體命令free -h whereis locate find查詢命令Linux記憶體
- Linux基礎命令---lpstat檢視列印任務Linux
- 使用netstat命令檢視埠的使用情況
- git檢視日誌的常用命令Git
- 使用 jstat 命令檢視 JVM 的GC資訊JSJVMGC