ps
查看进程,常用的用法有 ps -ef | grep xxxx 查看含xxxx字符串的进程 (如果xxxx是命令中的一段,而这个命令很长,xxxx位于最后面,这个程序就找不到了,看下面的ucb ps)
例子:
zhanju:/home/zhanju $ps -ef | grep was oracle 18112 1 0 Sep 23 ? 0:00 ora_s000_was oracle 18114 1 0 Sep 23 ? 0:00 ora_d000_was oracle 15886 1 0 Oct 25 ? 0:05 oraclewas (DESCRIPTION=(LOCAL=no)(ADDRESS=(PROTOCOL=BEQ))) oracle 18098 1 0 Sep 23 ? 0:13 ora_dbw0_was was 1509 10844 0 Oct 22 ? 7:26 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server was 17147 10844 0 Oct 25 ? 4:42 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server oracle 29411 1 0 18:21:09 ? 0:00 oraclewas (DESCRIPTION=(LOCAL=no)(ADDRESS=(PROTOCOL=BEQ))) oracle 5510 1 0 14:43:10 ? 1:25 oraclewas (DESCRIPTION=(LOCAL=no)(ADDRESS=(PROTOCOL=BEQ))) oracle 18104 1 0 Sep 23 ? 0:19 ora_smon_was oracle 18096 1 0 Sep 23 ? 0:00 ora_pmon_was zhanju 20586 19391 0 02:28:52 pts/16 0:00 grep was was 10844 29400 0 Oct 22 ? 172:28 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -Xmx128 was 10990 10844 0 Oct 27 ? 2:34 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server was 9507 1 0 Oct 22 ? 56:07 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server oracle 18110 1 0 Sep 23 ? 0:01 ora_snp1_was was 8809 10844 0 15:10:51 ? 2:55 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server was 10987 10844 0 Oct 22 ? 1:04 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server oracle 18100 1 0 Sep 23 ? 2:33 ora_lgwr_was oracle 18102 1 0 Sep 23 ? 9:41 ora_ckpt_was was 19692 10844 0 16:48:54 ? 1:44 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server was 6123 10844 0 14:48:44 ? 1:53 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server oracle 18108 1 0 Sep 23 ? 0:01 ora_snp0_was was 29395 1 0 Oct 15 ? 0:00 /bin/ksh /opt/WebSphere4/AppServer/bin/startupServer.sh 4001 oracle 18106 1 0 Sep 23 ? 0:00 ora_reco_was was 9079 10844 0 Oct 27 ? 19:08 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server was 28957 10844 0 18:17:04 ? 1:49 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server was 20841 10844 0 Oct 25 ? 2:50 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server was 29400 29395 0 Oct 15 ? 0:07 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -classp was 503 10844 0 13:58:37 ? 0:31 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server was 8631 10844 0 15:09:46 ? 1:57 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server oracle 14079 1 0 15:58:19 ? 0:01 oraclewas (DESCRIPTION=(LOCAL=no)(ADDRESS=(PROTOCOL=BEQ))) was 17080 10844 0 Oct 25 ? 22:12 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server was 2211 10844 0 Oct 27 ? 71:45 /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java -server zhanju:/home/zhanju $
ps -eo pid,user,comm,pcpu,pmem 查看指定的一些进程属性,o后面的就是属性,具体请看manual page
例子:
zhanju:/home/zhanju $ps -eo pid,user,comm,pcpu,pmem | grep was 18112 oracle ora_s000_was 0.0 1.6 18114 oracle ora_d000_was 0.0 1.6 15886 oracle oraclewas 0.0 1.6 18098 oracle ora_dbw0_was 0.0 1.6 1509 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 3.1 17147 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 2.2 29411 oracle oraclewas 0.0 1.6 5510 oracle oraclewas 0.0 1.6 18104 oracle ora_smon_was 0.0 1.6 18096 oracle ora_pmon_was 0.0 1.6 10844 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 3.5 10990 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 1.6 9507 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 23.3 18110 oracle ora_snp1_was 0.0 1.6 8809 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 4.9 10987 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 1.3 18100 oracle ora_lgwr_was 0.0 1.6 18102 oracle ora_ckpt_was 0.0 1.6 19692 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 2.8 6123 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 2.3 18108 oracle ora_snp0_was 0.0 1.7 29395 was /bin/ksh 0.0 0.1 18106 oracle ora_reco_was 0.0 1.6 9079 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.1 4.4 28957 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 2.4 20841 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 2.4 29400 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 0.6 503 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 1.5 8631 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.0 1.8 14079 oracle oraclewas 0.0 1.6 17080 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.1 3.8 2211 was /opt/WebSphere4/AppServer/java/jre/bin/../bin/sparc/native_threads/java 0.5 3.4 zhanju:/home/zhanju $
ucb ps
这个命令和/bin/ps是有区别的,用它能看到完整的进程命令行,用法是
/usr/ucb/ps -alxww
例子:
zhanju:/home/zhanju $/usr/ucb/ps -alxww | grep httpd 8 0 997 1 0 59 2011528 8712 mutex_ex S ? 0:03 /opt/IBMHTTPD/bin/httpd 8 60001 1147 997 0 59 2012120 7016 mutex_ex S ? 0:33 /opt/IBMHTTPD/bin/httpd 8 60001 1148 997 0 59 2012128 6992 mutex_ex S ? 0:32 /opt/IBMHTTPD/bin/httpd 8 60001 1149 997 0 59 2012128 7224 mutex_ex S ? 0:32 /opt/IBMHTTPD/bin/httpd 8 60001 1150 997 0 59 2012128 6944 mutex_ex S ? 0:32 /opt/IBMHTTPD/bin/httpd 8 60001 1151 997 0 59 2012120 6232 mutex_ex S ? 0:32 /opt/IBMHTTPD/bin/httpd 8 60001 3130 997 0 59 2012120 6280 mutex_ex S ? 0:33 /opt/IBMHTTPD/bin/httpd 8 60001 3656 997 0 60 2012096 6968 mutex_ex S ? 0:32 /opt/IBMHTTPD/bin/httpd 8 60001 7240 997 0 59 2012128 6256 udp_g_lo S ? 0:32 /opt/IBMHTTPD/bin/httpd 8 60001 7241 997 0 59 2012144 6440 mutex_ex S ? 0:31 /opt/IBMHTTPD/bin/httpd 8 60001 20113 997 0 59 2012176 7264 mutex_ex S ? 0:32 /opt/IBMHTTPD/bin/httpd 8 39650 20935 19391 0 59 20 1032 784 mutex_ex S pts/16 0:00 grep httpd zhanju:/home/zhanju $
prstat
查看当前系统进程
常用的是 prstat -u username
例子:
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP 2211 was 277M 196M sleep 59 0 1:11.50 0.2% java/27 9079 was 406M 257M sleep 59 0 0:19.09 0.1% java/25 17080 was 292M 220M sleep 59 0 0:22.12 0.0% java/27 10844 was 279M 206M sleep 59 0 2:52.27 0.0% java/115 20841 was 160M 137M sleep 59 0 0:02.50 0.0% java/23 6123 was 280M 132M sleep 59 0 0:01.53 0.0% java/21 17147 was 265M 129M sleep 59 0 0:04.41 0.0% java/39 8631 was 255M 106M sleep 59 0 0:01.57 0.0% java/27 503 was 244M 86M sleep 59 0 0:00.31 0.0% java/14 29400 was 95M 34M sleep 59 0 0:00.06 0.0% java/8 28957 was 162M 142M sleep 59 0 0:01.49 0.0% java/26 29395 was 1912K 1400K sleep 59 0 0:00.00 0.0% startupServer.s/1 19692 was 264M 165M sleep 59 0 0:01.44 0.0% java/24 10987 was 148M 77M sleep 59 0 0:01.04 0.0% java/20 8809 was 656M 287M sleep 59 0 0:02.55 0.0% java/26 9507 was 1473M 1368M sleep 59 0 0:56.07 0.0% java/29 10990 was 165M 89M sleep 59 0 0:02.34 0.0% java/20 1509 was 212M 183M sleep 59 0 0:07.26 0.0% java/24

|