1、查看线程号:
% ps -aHxo lwp,comm
grep mysql
100147 mysqld/mysqld
100316 mysqld/mysqld
100317 mysqld/mysqld
100318 mysqld/mysqld
100319 mysqld/mysqld
100320 mysqld/mysqld
……
2、显示线程信息:
(行太长,显示不完整)
ps -axH
grep mysql
1549 ?? S 0:11.75 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var
1549 ?? I 0:00.00 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var
1549 ?? I 0:00.00 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var
1549 ?? I 0:00.00 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var
1549 ?? I 0:00.00 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var
1549 ?? I 0:00.00 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var
1549 ?? I 0:00.00 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var
3、查看运行命令,包括指定的参数,用它来找mysql数据库存储位置还是比较好的:
ps -axww
grep mysql
# ps -axww
grep mysql
1213 ?? Is 0:00.01 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --pid-file=/var/db/mysql/mm.test.com.pid
1549 ?? I 520:50.29 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --datadir=/var/db/mysql --plugin-dir=/usr/local/lib/mysql/plugin --log-error=/var/db/mysql/mm.test.com.err --pid-file=/var/db/mysql/mm.test.com.pid --socket=/tmp/mysql.sock --port=3306
4、查看用户环境变量:
(以下命令显示不完整,因为ps默认不换行)
%ps -e
PID TT STAT TIME COMMAND
1405 0 Is 0:00.02 USER=test LOGNAME=test HOME=/home/test MAIL=/var/mail/test PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/test/bin TERM=vt100 BLOCKSIZE=K ……
1798 1 Ss 0:00.01 USER=test LOGNAME=test HOME=/home/test MAIL=/var/mail/test PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/test/bin TERM=vt100 BLOCKSIZE=K ……
1809 1 R+ 0:00.00 USER=test LOGNAME=test HOME=/home/test MAIL=/var/mail/test PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/test/bin TERM=vt100 BLOCKSIZE=K ……
5、查看某个用户运行的程序,在多用户机器上较常用:
# ps -axwwU test
PID TT STAT TIME COMMAND
70150 ?? S 0:00.52 sshd: test@pts/0 (sshd)
75968 ?? I 0:00.12 sshd: test@pts/1 (sshd)
70151 0 Is 0:00.01 -csh (csh)
75969 1 Is+ 0:00.01 -csh (csh)
7604 2 Is+ 0:00.04 /bin/csh
6、虚拟机的jail信息查看(FreeBSD10.1以后版本):
ps -axwJ 1
该贴由hui.chen转至本版2015-1-5 10:17:04