页面“检测指定文件夹内的ipa的版本号”与“每天一命令之Ps”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
(导入1个版本)
 
(导入1个版本)
 
第1行: 第1行:
 +
=ps=
 +
==NAME and DESCRIPTION==
 +
ps - report a snapshot of the current processes.
 +
ps displays information about a selection of the active processes.
 +
 +
Process Status ?
 +
==OPTIONS==
 +
<pre>
 +
a  显示所有进程 all w/ tty, including other users
 +
-a 显示同一终端下的所有程序 all w/ tty except session leaders
 +
-A 显示所有进程 all processes
 +
c  显示进程的真实名称
 +
-N 反向选择
 +
-e 等于“-A”
 +
-f:显示UID,PPIP,C与STIME栏位。
 +
e  显示环境变量
 +
f  显示程序间的关系
 +
-H 显示树状结构
 +
r  显示当前终端的进程
 +
T  显示当前终端的所有程序
 +
u  指定用户的所有进程
 +
-au 显示较详细的资讯
 +
u:以用户为主的格式来显示程序状况。
 +
-aux 显示所有包含其他使用者的行程
 +
-C<命令> 列出指定命令的状况
 +
--lines<行数> 每页显示的行数
 +
--width<字符数> 每页显示的字符数
 +
 +
-l或l:采用详细的格式来显示程序状况。
 +
 +
-y:配合选项"-l"使用时,不显示F(flag)栏位,并以RSS栏位取代ADDR栏位。 Do not show flags; show rss in place of addr.  This option can only be used with -l.
 +
 +
-C by command name <指令名称>:指定执行指令的名称,并列出该指令的程序的状况
 +
 +
-o 用户自定义格式。 Specify user-defined format.  Identical to -o and --format
 +
 +
-o format
 +
      User-defined format.  format is a single argument in the form of a blank-separated or
 +
      comma-separated list, which offers a way to specify individual output columns.  The
 +
      recognized keywords are described in the STANDARD FORMAT SPECIFIERS section below.
 +
      Headers may be renamed (ps -o pid,ruser=RealUser -o comm=Command) as desired.  If all
 +
      column headers are empty (ps -o pid= -o comm=) then the header line will not be
 +
      output.  Column width will increase as needed for wide headers; this may be used to
 +
      widen up columns such as WCHAN (ps -o pid,wchan=WIDE-WCHAN-COLUMN -o comm).  Explicit
 +
      width control (ps opid,wchan:42,cmd) is offered too.  The behavior of ps -o pid=X,
 +
      comm=Y varies with personality; output may be one column named "X,comm=Y" or two
 +
      columns named "X" and "Y".  Use multiple -o options when in doubt.  Use the PS_FORMAT
 +
      environment variable to specify a default as desired; DefSysV and DefBSD are macros
 +
      that may be used to choose the default UNIX or BSD columns.
 +
 +
</pre>
 +
 +
 +
==EXAMPLES==
 
<pre>
 
<pre>
#!/bin/bash
+
ps找出消耗内存的元凶 找出最占用内存的进程
for ipas in $1/*
+
ps -A --sort -rss -o comm,pmem,pcpu   |uniq -c | head -10
do
+
      1 COMMAND         %MEM %CPU
    if [ "${ipas##*.}" = "ipa" ];then    
+
      1 java            1.5  4.9
         if [ ! -d "Payload" ]; then
+
      1 java            1.3  0.2
          unzip -q $ipas
 
        fi
 
  
        ipa=$(basename ${ipas##*/} .ipa)
+
      8 nginx            0.1  0.8
        version=`plutil -p Payload/*.app/Info.plist | grep 'CFBundleShortVersionString'|cut -d '"' -f 4`
 
  
        echo ${ipa}" 版本="${version} >> $1/version.txt
 
        rm -rf  Payload META-INF
 
  fi
 
done
 
  
 +
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head
  
Mac-mini:chuan$ ls src/
 
bb.ipa cc.ipa
 
Mac-mini:chuan$  sh evan.sh  src/
 
Mac-mini:chuan$  cat src/version.txt
 
bb 版本=1.0.0
 
cc 版本=1.0.0
 
  
检测指定文件夹内的ipa的版本号
+
查看每个FPM的内存占用:#RSS段为内存
http://www.jianshu.com/p/8178962aba8e
+
ps -ylC php-fpm --sort:rss
 +
S  UID  PID  PPID  C PRI  NI  RSS    SZ WCHAN  TTY          TIME CMD
 +
S    0 21556    1  0  80  0  8388 75039 ep_pol ?        00:01:16 php-fpm
 +
S  498  6349 21556  0  80  0 11728 811119 inet_c ?      00:01:46 php-fpm
 +
S  498 21564 21556  0  80  0 14940 2053445 inet_c ?      00:04:42 php-fpm
 +
S  498 21693 21556  0  80  0 14944 2054981 inet_c ?      00:04:44 php-fpm
 +
S  498 21735 21556  0  80  0 14944 2054789 inet_c ?      00:04:45 php-fpm
  
 +
ps命令常用用法(方便查看系统进程)
  
if else以及大于、小于、等于逻辑表达式
+
1)ps a 显示现行终端机下的所有程序,包括其他用户的程序。
 +
2)ps -A 显示所有进程。
 +
3)ps c 列出程序时,显示每个程序真正的指令名称,而不包含路径,参数或常驻服务的标示。
 +
4)ps -e 此参数的效果和指定"A"参数相同。
 +
5)ps e 列出程序时,显示每个程序所使用的环境变量。
 +
6)ps f 用ASCII字符显示树状结构,表达程序间的相互关系。
 +
7)ps -H 显示树状结构,表示程序间的相互关系。
 +
8)ps -N 显示所有的程序,除了执行ps指令终端机下的程序之外。
 +
9)ps s 采用程序信号的格式显示程序状况。
 +
10)ps S 列出程序时,包括已中断的子程序资料。
 +
11)ps -t<终端机编号>  指定终端机编号,并列出属于该终端机的程序的状况。
 +
12)ps u  以用户为主的格式来显示程序状况。
 +
13)ps x  显示所有程序,不以终端机来区分。
 +
最常用的方法是ps -aux,然后再利用一个管道符号导向到grep去查找特定的进程,然后再对特定的进程进行操作。
  
==比较容易混的知识点==
+
</pre>
  
shell 字符串比较:
+
==运行时间查看==
=                         等于          if [ "$a" = "$b" ]
+
<pre>
==                       与=等价
+
ps -eo pid,lstart,etime,cmd | grep tomcat6
 +
28781 Thu Oct 25 10:19:41 2018    07:13:10
  
 +
#10:19分启动的
 
</pre>
 
</pre>
  
If else以及大于、小于、等于逻辑表达式
+
=SEE ALSO=
https://wiki.linuxchina.net/index.php?title=If_else%E4%BB%A5%E5%8F%8A%E5%A4%A7%E4%BA%8E%E3%80%81%E5%B0%8F%E4%BA%8E%E3%80%81%E7%AD%89%E4%BA%8E%E9%80%BB%E8%BE%91%E8%A1%A8%E8%BE%BE%E5%BC%8F
+
[http://man.linuxde.net/ps ps命令]
 +
 
 +
[http://www.cnblogs.com/wangkangluo1/archive/2011/09/23/2185938.html ps命令详解] 
 +
 
 +
[http://www.cnblogs.com/peida/archive/2012/12/19/2824418.html 每天一个linux命令(41):ps命令]
 +
 
 +
[http://linuxtools-rst.readthedocs.io/zh_CN/latest/tool/ps.html  ps 进程查看器]
 +
 
 +
[http://jaminzhang.github.io/linux/using-ps-to-view-process-started-and-elapsed-time-in-linux/ Linux ps 命令查看进程启动及运行时间]
 +
 
 +
[http://blog.linuxchina.net/?p=2950 好玩的ps –no-heading]
  
Shell之提取文件名和目录名的一些方法
+
[https://jaminzhang.github.io/linux/using-ps-to-view-process-started-and-elapsed-time-in-linux/ Linux ps 命令查看进程启动及运行时间]
https://wiki.linuxchina.net/index.php?title=Shell%E4%B9%8B%E6%8F%90%E5%8F%96%E6%96%87%E4%BB%B6%E5%90%8D%E5%92%8C%E7%9B%AE%E5%BD%95%E5%90%8D%E7%9A%84%E4%B8%80%E4%BA%9B%E6%96%B9%E6%B3%95
 
  
[[category:shell]]
+
[[category:ops]][[category:linux]]

2019年10月14日 (一) 13:55的版本

ps

NAME and DESCRIPTION

ps - report a snapshot of the current processes. ps displays information about a selection of the active processes.

Process Status ?

OPTIONS

a  显示所有进程 all w/ tty, including other users
-a 显示同一终端下的所有程序 all w/ tty except session leaders 
-A 显示所有进程 all processes 
c  显示进程的真实名称
-N 反向选择
-e 等于“-A”
-f:显示UID,PPIP,C与STIME栏位。
e  显示环境变量
f  显示程序间的关系
-H 显示树状结构
r  显示当前终端的进程
T  显示当前终端的所有程序
u  指定用户的所有进程
-au 显示较详细的资讯
u:以用户为主的格式来显示程序状况。
-aux 显示所有包含其他使用者的行程 
-C<命令> 列出指定命令的状况
--lines<行数> 每页显示的行数
--width<字符数> 每页显示的字符数

-l或l:采用详细的格式来显示程序状况。

-y:配合选项"-l"使用时,不显示F(flag)栏位,并以RSS栏位取代ADDR栏位。 Do not show flags; show rss in place of addr.  This option can only be used with -l.

-C by command name <指令名称>:指定执行指令的名称,并列出该指令的程序的状况

-o 用户自定义格式。 Specify user-defined format.  Identical to -o and --format

-o format
      User-defined format.  format is a single argument in the form of a blank-separated or
      comma-separated list, which offers a way to specify individual output columns.  The
      recognized keywords are described in the STANDARD FORMAT SPECIFIERS section below.
      Headers may be renamed (ps -o pid,ruser=RealUser -o comm=Command) as desired.  If all
      column headers are empty (ps -o pid= -o comm=) then the header line will not be
      output.  Column width will increase as needed for wide headers; this may be used to
      widen up columns such as WCHAN (ps -o pid,wchan=WIDE-WCHAN-COLUMN -o comm).  Explicit
      width control (ps opid,wchan:42,cmd) is offered too.  The behavior of ps -o pid=X,
      comm=Y varies with personality; output may be one column named "X,comm=Y" or two
      columns named "X" and "Y".  Use multiple -o options when in doubt.  Use the PS_FORMAT
      environment variable to specify a default as desired; DefSysV and DefBSD are macros
      that may be used to choose the default UNIX or BSD columns.


EXAMPLES

ps找出消耗内存的元凶 找出最占用内存的进程
ps -A --sort -rss -o comm,pmem,pcpu   |uniq -c | head -10
      1 COMMAND         %MEM %CPU
      1 java             1.5  4.9
      1 java             1.3  0.2

      8 nginx            0.1  0.8


ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head


查看每个FPM的内存占用:#RSS段为内存
ps -ylC php-fpm --sort:rss
S   UID   PID  PPID  C PRI  NI   RSS    SZ WCHAN  TTY          TIME CMD
S     0 21556     1  0  80   0  8388 75039 ep_pol ?        00:01:16 php-fpm
S   498  6349 21556  0  80   0 11728 811119 inet_c ?       00:01:46 php-fpm
S   498 21564 21556  0  80   0 14940 2053445 inet_c ?      00:04:42 php-fpm
S   498 21693 21556  0  80   0 14944 2054981 inet_c ?      00:04:44 php-fpm
S   498 21735 21556  0  80   0 14944 2054789 inet_c ?      00:04:45 php-fpm

ps命令常用用法(方便查看系统进程)

1)ps a 显示现行终端机下的所有程序,包括其他用户的程序。
2)ps -A 显示所有进程。
3)ps c 列出程序时,显示每个程序真正的指令名称,而不包含路径,参数或常驻服务的标示。
4)ps -e 此参数的效果和指定"A"参数相同。
5)ps e 列出程序时,显示每个程序所使用的环境变量。
6)ps f 用ASCII字符显示树状结构,表达程序间的相互关系。
7)ps -H 显示树状结构,表示程序间的相互关系。
8)ps -N 显示所有的程序,除了执行ps指令终端机下的程序之外。
9)ps s 采用程序信号的格式显示程序状况。
10)ps S 列出程序时,包括已中断的子程序资料。
11)ps -t<终端机编号>  指定终端机编号,并列出属于该终端机的程序的状况。
12)ps u  以用户为主的格式来显示程序状况。
13)ps x  显示所有程序,不以终端机来区分。
最常用的方法是ps -aux,然后再利用一个管道符号导向到grep去查找特定的进程,然后再对特定的进程进行操作。

运行时间查看

ps -eo pid,lstart,etime,cmd | grep tomcat6
28781 Thu Oct 25 10:19:41 2018    07:13:10 

#10:19分启动的

SEE ALSO

ps命令

ps命令详解

每天一个linux命令(41):ps命令

ps 进程查看器

Linux ps 命令查看进程启动及运行时间

好玩的ps –no-heading

Linux ps 命令查看进程启动及运行时间