Last Updated: 2023-06-24 13:54:12 Saturday
-- TOC --
ps,process statue
,用于查看系统进程状态的命令,ps命令显示出来的是系统当前进程及相关信息的一个快照。
如果需要动态显示(不断刷新)进程状态,使用top命令,或者用ps配合watch命令。
-e
,显示系统所有当前进程:
$ ps -e # or -A, standard display syntax
$ ps -ef # -f, full-format listing
$ ps -eF # -F, extra full-format
$ ps -elf # -l, long format,跟多列,含PRI和NI
$ ps -elF
$ ps -elfy # -y, only used with -l,不显示flag列
$ ps -elFy
-U <username>
,按用户(RUID)查询进程:
-u这个参数貌似有问题...EUID和RUID又有什么区别?
-L
,显示线程:
对所有进程按CPU使用率进行排序:
$ ps aux --sort pcpu | tail -n5 # from small to big, so tail
$ ps aux | sort -rnk3 | head -n5 # use sort, column 3 is cpu usage info
显示出来的信息还是有些凌乱,主要是CMD列有点长。
对所有进程按MEM占用进行排序:
$ ps aux --sort pmem | tail -n5
$ ps aux | sort -rnk4 | head -n5 # sort column 4
ps aux
是BSD风格显示。
Process State Codes
Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process:
D
uninterruptible sleep (usually IO)I
Idle kernel threadR
running or runnable (on run queue)S
interruptible sleep (waiting for an event to complete)T
stopped by job control signalt
stopped by debugger during the tracingW
paging (not valid since the 2.6.xx kernel)X
dead (should never be seen)Z
defunct ("zombie") process, terminated but not reaped by its parentFor BSD formats and when the stat keyword is used, additional characters may be displayed:
<
high-priority (not nice to other users)N
low-priority (nice to other users)L
has pages locked into memory (for real-time and custom IO)s
is a session leaderl
is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)+
is in the foreground process group本文链接:https://cs.pynote.net/sf/linux/shell/202201101/
-- EOF --
-- MORE --