Linux命令 --- ps/pstack/pstree

pstack
pstack pid
显示某个进程的栈跟踪,必须在对应的用户组或root下操作。

[wuchunlai@s1 ~]$ sudo -u work pstack $(pgrep cc_engine)
Thread 3 (Thread 0x7fb3467ff700 (LWP 6130)):
#0  0x000000370cae5d03 in epoll_wait () from /lib64/libc.so.6
#1  0x000000000042af06 in cc_loop_run ()
#2  0x0000000000418019 in cc_single_send_start ()
#3  0x000000370ce077f1 in start_thread () from /lib64/libpthread.so.0
#4  0x000000370cae570d in clone () from /lib64/libc.so.6
Thread 2 (Thread 0x7fb345dfe700 (LWP 6131)):
#0  0x000000370caaab9d in nanosleep () from /lib64/libc.so.6
#1  0x000000370caaaa10 in sleep () from /lib64/libc.so.6
#2  0x00000000004083b1 in cc_collect_log ()
#3  0x000000370ce077f1 in start_thread () from /lib64/libpthread.so.0
#4  0x000000370cae570d in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x7fb346ca2840 (LWP 6128)):
#0  0x000000370ca32c34 in sigsuspend () from /lib64/libc.so.6
#1  0x0000000000433d42 in cc_sig_wait ()
#2  0x000000000040600c in cc_client_process ()
#3  0x0000000000405be2 in cc_run ()
#4  0x0000000000405c2a in main ()

pstree
pstree
以树状结构显示所有进程的关系,只显示进程名字,并且相同进程合并。

pstree -p
显示所有的进程,并添加进程号

pstree -p
显示进程PID为的进程以及子孙进程,如果有-p则显示每个进程的PID。

pstree -a
相同名称进程不合并,并且会显示命令行参数

pstree
可以跟一个用户参数,表示显示哪个用户的进程列表。

因为pstree输出的信息可能比较多,所以最好与more/less配合使用。

[wuchunlai@s1 ~]$ pstree -p $(pgrep cc_engine)
cc_engine(6128)─┬─{cc_engine}(6130)
                └─{cc_engine}(6131)

ps
-A/e 列出所有的进程
-a 显示一个终端的所有进程,除了会话引线
-d 显示所有进程,省略所有回话引线
-x 显示没有控制终端的进程,同时显示各个命令的具体路径。dx不可合用。
-w 显示加宽可以显示较多的资讯
-f 列出全部选项
-o 用户自定义格式 pid/uname/pcpu/pmem/rsz/comm

-p pid 显示pid使用的cpu时间
-u uid/user 选择用户
-g gid/group 选择组
-C name 选择进程
–sort=-pcpu,+pmem 根据后加选项进行排序,-表示降序+表示升序

ps aux == ps -ef 列出所有进程
ps -fC … == ps -ef | grep …

install -d -m0755 /home/felix/mydisk/enterprise_gateway/bin/cn913x-cn25g-vpp_v1/packages ipkg-build -c -o 0 -g 0 /home/felix/mydisk/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/gdb-8.1/ipkg-cn913x/gdb /home/felix/mydisk/enterprise_gateway/bin/cn913x-cn25g-vpp_v1/packages Packaged contents of /home/felix/mydisk/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/gdb-8.1/ipkg-cn913x/gdb into /home/felix/mydisk/enterprise_gateway/bin/cn913x-cn25g-vpp_v1/packages/gdb_8.1-1_cn913x.ipk rm -rf /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/root-cn913x/tmp-gdb mkdir -p /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/root-cn913x/stamp /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/root-cn913x/tmp-gdb install -d -m0755 /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/root-cn913x/tmp-gdb/usr/bin /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/root-cn913x/tmp-gdb/usr/sbin/ install -m0755 /home/felix/mydisk/enterprise_gateway/build_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/gdb-8.1/ipkg-install/usr/bin/gdb /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/root-cn913x/tmp-gdb/usr/bin/ install -m0755 ./files/usr/sbin/pstack /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/root-cn913x/tmp-gdb/usr/sbin/ SHELL= /home/felix/mydisk/enterprise_gateway/staging_dir/host/bin/flock /home/felix/mydisk/enterprise_gateway/tmp/.root-copy.flock -c 'cp -fpR /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/root-cn913x/tmp-gdb/. /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/root-cn913x/' rm -rf /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/root-cn913x/tmp-gdb touch /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/root-cn913x/stamp/.gdb_installed if [ -f /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/pkginfo/gdb.default.install.clean ]; then rm -f /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/pkginfo/gdb.default.install /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/pkginfo/gdb.default.install.clean; fi; echo "gdb" >> /home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/pkginfo/gdb.default.install WARNING: skipping gdbserver -- package not selected make[3]: Leaving directory '/home/felix/mydisk/enterprise_gateway/package/devel/gdb' make[2]: Leaving directory '/home/felix/mydisk/enterprise_gateway' package/Makefile:190: recipe for target '/home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/stamp/.package_compile' failed make[1]: *** [/home/felix/mydisk/enterprise_gateway/staging_dir/target-aarch64-marvell-linux-gnu-cn25g-vpp_v1/stamp/.package_compile] Error 2 make[1]: Leaving directory '/home/felix/mydisk/enterprise_gateway' /home/felix/mydisk/enterprise_gateway/include/toplevel.mk:171: recipe for target 'world' failed make: *** [world] Error 2
最新发布
07-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值