- 浏览: 134750 次
- 性别:
- 来自: 成都
文章分类
最新评论
【基本介绍】
ps - report a snapshot of the current processes.
ps displays information about a selection of the active processes。
ps显示与进程相关的信息。
【基本参数】
【简单实例】
1. Display all processes(显示所有进程)
2. Display process by user(显示对应用户的进程)
3. Show process by name or process id(显示命令对应的进程)
4. Sort process by cpu or memory usage(针对列进行排序)
5. Display threads of a process(显示进程的线程)
6. Change the columns to display(格式化初始列)
7. Display elapsed time of processes(显示运行时间)
8. Turn ps into an realtime process viewer(实时查看进程,可以用top)
9. Finding memory Leak (ps –sort pmem)
if RSS (resident set size, in KB) increases over time (so would %MEM), it may indicate a memory leak in the application.如果RSS数值在变大,占用的MEM百分比也在变大,可以作为内存泄漏的依据.
【参考引用】
http://www.binarytides.com/linux-ps-command/
http://www.thegeekstuff.com/2011/04/ps-command-examples/
ps - report a snapshot of the current processes.
ps displays information about a selection of the active processes。
ps显示与进程相关的信息。
【基本参数】
-a Select all processes except both session leaders (see getsid(2)) and processes not associated with a terminal. a Lift the BSD-style "only yourself" restriction, -e Select all processes. Identical to -A. -C cmdlist Select by command name. -U userlist select by real user ID (RUID) or name. -p pidlist Select by PID. -f does full-format listing. This option can be combined with many other UNIX-style options to add additional columns. -o format user-defined format. -L Show threads, possibly with LWP and NLWP columns --sort spec specify sorting order args COMMAND command with all its arguments as a string. rss RSS resident set size, the non-swapped physical memory that a task has used (in kiloBytes)
【简单实例】
1. Display all processes(显示所有进程)
$ ps ax $ ps -ef
2. Display process by user(显示对应用户的进程)
[root@pandaVM ~]# ps -u root PID TTY TIME CMD 1 ? 00:00:28 init 2 ? 00:00:00 kthreadd 3 ? 00:00:00 migration/0 4 ? 00:00:08 ksoftirqd/0 5 ? 00:00:00 migration/0 6 ? 00:00:02 watchdog/0 7 ? 00:10:16 events/0 8 ? 00:00:00 cgroup 9 ? 00:00:00 khelper 10 ? 00:00:00 netns 11 ? 00:00:00 async/mgr 12 ? 00:00:00 pm 13 ? 00:00:05 sync_supers
3. Show process by name or process id(显示命令对应的进程)
$ ps -C apache2 PID TTY TIME CMD 2359 ? 00:00:00 apache2 4524 ? 00:00:00 apache2 4525 ? 00:00:00 apache2
4. Sort process by cpu or memory usage(针对列进行排序)
$ ps aux --sort=-pcpu | head -5 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 2.6 0.7 51396 7644 ? Ss 02:02 0:03 /usr/lib/systemd/systemd --switched-root --system --deserialize 23 root 1249 2.6 3.0 355800 30896 tty1 Rsl+ 02:02 0:02 /usr/bin/X -background none :0 vt01 -nolisten tcp root 508 2.4 1.6 248488 16776 ? Ss 02:02 0:03 /usr/bin/python /usr/sbin/firewalld --nofork silver 1525 2.1 2.3 448568 24392 ? S 02:03 0:01 /usr/bin/python /usr/share/system-config-printer/applet.py
5. Display threads of a process(显示进程的线程)
[root@pandaVM ~]# ps -p 38027 -L PID LWP TTY TIME CMD 38027 38027 ? 00:00:15 memcached 38027 38029 ? 00:00:00 memcached 38027 38030 ? 00:00:00 memcached 38027 38031 ? 00:00:00 memcached
6. Change the columns to display(格式化初始列)
$ ps -e -o pid,uname=USERNAME,pcpu=CPU_USAGE,pmem,comm PID USERNAME CPU_USAGE %MEM COMMAND 1 root 0.0 0.0 init 2 root 0.0 0.0 kthreadd 3 root 0.0 0.0 ksoftirqd/0 4 root 0.0 0.0 kworker/0:0 5 root 0.0 0.0 kworker/0:0H
7. Display elapsed time of processes(显示运行时间)
[root@pandaVM ~]# ps -e -o pid,comm,etime PID COMMAND ELAPSED 1 init 11-22:57:09 2 kthreadd 11-22:57:09 3 migration/0 11-22:57:09 4 ksoftirqd/0 11-22:57:09 5 migration/0 11-22:57:09 6 watchdog/0 11-22:57:09
8. Turn ps into an realtime process viewer(实时查看进程,可以用top)
[root@pandaVM ~]# watch -n 1 'ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pmem,-pcpu | head -15' Every 1.0s: ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pmem,-pcpu | head -15 Mon Oct 20 14:16:32 2014 PID USER CMD %MEM %CPU 41664 root watch -n 1 ps -e -o pid,una 0.2 0.3 2051 mysql /usr/libexec/mysqld --based 2.6 0.2 1 root /sbin/init 0.1 0.0 2 root [kthreadd] 0.0 0.0
9. Finding memory Leak (ps –sort pmem)
$ ps ev --pid=27645 PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 27645 ? S 3:01 0 25 1231262 1183976 14.4 /TaskServer/bin/./wrapper-linux-x86-32
if RSS (resident set size, in KB) increases over time (so would %MEM), it may indicate a memory leak in the application.如果RSS数值在变大,占用的MEM百分比也在变大,可以作为内存泄漏的依据.
【参考引用】
http://www.binarytides.com/linux-ps-command/
http://www.thegeekstuff.com/2011/04/ps-command-examples/
发表评论
-
linux shell - 远端修改非root密码
2015-01-09 20:40 955【基本介绍】 通过远端修改普通用户密码,而passwd --s ... -
linux shell - broken pip error
2015-01-07 15:36 2664【基本介绍】 这里我们介绍发生broken pipe错误的原因 ... -
linux locate - find files by name
2014-12-17 17:46 561【基本介绍】 这里我们介绍locate命令,用来查找文件。 ... -
linux ssh - GSSAPIAuthentication
2014-12-10 14:58 2001【基本介绍】 最近公司搬家,发现合作伙伴的服务器的用ftp工具 ... -
linux tar - 压缩解压
2014-12-01 16:04 969【基本介绍】 今天遇到要添加文件到tar文件里面,所以在这里介 ... -
linux parameter substitution - 字符串/变量处理
2014-11-17 15:56 778【基本介绍】 这里我们介绍bash里面对字符串,变量等的替换等 ... -
linux netstat - status状态描述
2014-11-14 17:59 1113【基本介绍】 这里介绍netstat命令返回的结果status ... -
linux set - set variables and set positional parameters
2014-11-10 18:26 406【基本介绍】 set是shell的内置命令。可以用来设置修改变 ... -
linux nc - arbitrary TCP and UDP connections and listens
2014-10-31 17:46 759【基本介绍】 nc是可以打开任意端口的TCP/UDP连接和监听 ... -
linux 报错集 - Cannot retrieve metalink for repository: epel. Please verify its pat
2014-10-29 15:12 925【基本介绍】 运行yum报错Error: Cannot ret ... -
linux awk - awk tutorial
2014-10-21 10:47 458【基本介绍】 awk是一款强大的对文件内容进行处理的软件,可以 ... -
linux lsof - list open files
2014-10-17 17:31 711【基本介绍】 lsof - list open files I ... -
linux - 网络连接状态
2014-10-13 11:00 1350【基本情况】 这里介绍 ... -
linux netstat - Print network connections, routing tables, interface statistics,
2014-10-13 10:37 978【基本介绍】 netstat - Print network ... -
linux vmstat - Report virtual memory statistics
2014-10-10 17:39 692【基本介绍】 vmstat - Report virtual ... -
linux yum - yum warning: rpmts_HdrFromFdno
2014-10-09 15:08 560【基本介绍】 在yum安装软件的时候有时候会报warning: ... -
Linux ip subnet mask - 网段分析
2014-09-24 19:22 1293【基本介绍】 网段的分析可以帮助我们查看两个局域地址是否可以互 ... -
linux curl - curl 上传下载
2014-09-19 11:45 2074【基本介绍】 curl is a tool to tra ... -
linux mkpasswd - 密码生成器
2014-09-18 17:18 1380【基本介绍】 作为linux admin要经常创建用户,并初始 ... -
linux dd - dd测试硬盘速度
2014-09-05 18:42 816【基本介绍】 这里我们使用dd命令来测试硬盘的读写速度 dd ...
相关推荐
深度学习neural-processes的代码,可以运行测试,是学习neural-processes的入门参考代码,包含neural-processes设计算法的基本功能及思路。
本书受理解Unix进程启发而作,用极简的篇幅深入学习进程知识。理解Linux进程用Go重写了所有示例程序,通过循序渐进的方法介绍Linux进程的工作原理和一切你所需要知道的概念。本书适合所有Linux程序员阅读。
LO020-processes in procurement
Stochastic-Processes-master 课件
ch3-Processes.ppt
Unit-12-Material-Forming-Processes-机电专业英语-图文课件.ppt
A-survey-of-the-application-of-gamma-processes-in-maintenance_2009_Reliability-Engineering-System-Safety
Solar Energy Engineering - Processes and Systems 2009 ISBN 978-0-12-374501-9
Probability-Theory——Stochastic-Processes.pdf Athanasios
The third and final group of chapters − 9to14 − tackles the Model Predictive Control approach to dead-time compensation. These chapters range from the fundamentals of GPC and DMC in Chapter 9, ...
操作系统概念英文课件:Chapter 03-processes[14].pptx
理解unix进程模型,以及unix环境编程相关原理,如何在unix环境中创建高效的系统级应用
The introduction of Agile processes for software development has brought many advantages to organizations that develop software. Relative to the preceding “Waterfall” approach, these advantages ...
这是关于决策处理的计算模型的电子书,高清,最新版本,经典著作,英文版
农民讲习所的建立mcu通用处理程序,觉得还不错,很好的学习资料,好东西啊
To that end, we propose a demonstration of PROPOLIS, a system for PROvisioned PrOcess anaLysIS, namely analy- sis of data-centric processes under hypothetical modification scenarios. Our solution is ...
Stability of Markovian processes II_ Continuous-time processes and sampled chains
SAP QM PLM400-Business Processes in Quality Management
Dirichlet过程自动从code.google.com/p/dirichlet-processes导出请注意,此代码不再受维护。 Dirichlet过程用于聚类/主题建模的分层Dirichlet流程增量Dirichlet流程用于拆分/合并分析请引用这两篇论文: @in...
转到克隆的目录: cd flex-example-processes让我们以my-marketplace-id作为示例Marketplace ID,并使用preauth-daily-booking作为使用的过程。 使用示例流程,为您的市场创建一个新流程: flex-cli process create ...