[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
[20230323]ps命令查看thread.txt
来源:这里教程网
时间:2026-03-03 18:32:18
作者:
编辑推荐:
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- 监控视频压缩存储对监狱-智慧监狱的解决方案
监控视频压缩存储对监狱-智慧监狱的解决方案
26-03-03 - 华为工单宝:制造业数字化转型利器,项目管理助力售后服务自动化
华为工单宝:制造业数字化转型利器,项目管理助力售后服务自动化
26-03-03 - 口含袋年复合增长30%,国内尼古丁口含袋会是新风口吗?
口含袋年复合增长30%,国内尼古丁口含袋会是新风口吗?
26-03-03 - Library Cache优化篇(一)降低library cache lock和library cache pin的方法
- 智慧城市监控视频存储解决方案
智慧城市监控视频存储解决方案
26-03-03 - 海量监控视频应该如何存储?
海量监控视频应该如何存储?
26-03-03 - 军队视频监控产生的数据应该如何存储?
军队视频监控产生的数据应该如何存储?
26-03-03 - Oracle PDB创建实操
Oracle PDB创建实操
26-03-03 - 唯亚威VIAVI光纤或5G测试仪对网络安全的解决方案
唯亚威VIAVI光纤或5G测试仪对网络安全的解决方案
26-03-03 - 抖音进攻,B站退守
抖音进攻,B站退守
26-03-03
