zoukankan      html  css  js  c++  java
  • PSProcess Status Anny

    From http://www.linux.ie/newusers/beginners-linux-guide/ps.php

    1. What does 'ps'mean?

    ps is the shortage for Process Status. The command should be used to display the currently running processes on Unix/Linux systems. If you know the 'Task-Manager' which pops up under Windows NT/2000/XP when you press CTRL+ALT+DEL then you have a clue what ps does under Unix/Linux. Ps can show you the running processes on your system in different ways. I will describe the basic ones you should know.

    2. Why is it good to know how the ps command works?

    If you have a process which seems to hang (e.g. netscape navigator on some buggy websites) and you want to stop the process, then you can determine the process id of the process. Why do you need the process id? You can stop the process with the help of the 'kill' command. The kill command needs a process number otherwise it won't know to which process it should send the 'kill' signal. Other example. You have started a process and now your machines becomes slower and slower. You stop the process but your machine still gets slower and slower. Now it will be helpful if you can stop the process. In this case you also need its pid.
    Next example: You want to know what processes your friend just uses (you know he has an remote session open), then you can also use the ps command to find out which processes belong to him.

    3. Some examples for the ps command

    3.1. Executing the ps command

    just enter 'ps' at the prompt:
    $ ps
    PID TTY          TIME CMD
    3511 pts/1    00:00:00 bash
    3514 pts/1    00:00:00 ps	
    

    3.2. Displaying all processes owned by a specific user


    $ ps ux
    USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
    heyne      691  0.0  2.4 19272 9576 ?        S    13:35   0:00 kdeinit: kded    
    heyne      700  0.1  1.0  5880 3944 ?        S    13:35   0:01 artsd -F 10 -S 40
    heyne      710  0.0  2.8 21876 11072 ?       S    13:35   0:00 kdeinit: knotify 
    heyne      711  0.0  0.0  1344  352 ?        S    13:35   0:00 kwrapper ksmserve
    heyne      713  0.0  2.4 18900 9304 ?        S    13:35   0:00 kdeinit: ksmserve
    heyne      714  0.0  2.9 21548 11528 ?       S    13:35   0:00 kdeinit: kwin -se
    heyne      715  0.3  4.8 31096 18820 ?       S    13:35   0:03 /usr/lib/mozilla/
    heyne      719  0.1  3.5 22548 13680 ?       S    13:35   0:01 kdeinit: kdesktop
    heyne      721  0.5  3.6 23904 14028 ?       S    13:35   0:05 kdeinit: kicker  
    heyne      722  0.0  2.0 18504 7824 ?        S    13:35   0:00 kdeinit: kio_file
    heyne      723  0.0  4.8 31096 18820 ?       S    13:36   0:00 /usr/lib/mozilla/
    heyne      724  0.0  4.8 31096 18820 ?       S    13:36   0:00 /usr/lib/mozilla/
    heyne      725  0.0  4.8 31096 18820 ?       S    13:36   0:00 /usr/lib/mozilla/
    heyne      729  0.0  2.4 19408 9404 ?        S    13:36   0:00 kdeinit: klaptopd
    heyne      730  0.0  2.3 17044 9152 ?        S    13:36   0:00 kteatime -session
    heyne      731  0.0  3.0 21236 11848 ?       S    13:36   0:00 kdeinit: kmix -se
    heyne      735  0.0  4.8 31096 18820 ?       S    13:36   0:00 /usr/lib/mozilla/
    heyne      736  0.0  2.7 20492 10600 ?       S    13:36   0:00 korgac --miniicon
    heyne      745  0.0  2.4 19232 9528 ?        S    13:36   0:00 kalarmd --login
    heyne      753  0.0  0.3  2108 1160 pts/0    S    13:36   0:00 bash
    heyne      787  0.7  1.7  9520 6784 ?        S    13:50   0:00 emacs
    heyne      789  0.2  0.3  2112 1164 pts/1    S    13:51   0:00 bash
    heyne      794  0.0  0.4  3560 1576 pts/1    R    13:51   0:00 ps ux                     
    

    You can also use the syntax "ps U username". In my case I use ps U heyne. If you use this syntax you get a result like the following:
    PID TTY      STAT   TIME COMMAND
    721 ?        S      0:08 kdeinit: kicker          
    722 ?        S      0:00 kdeinit: kio_file file /tmp/ksocket-heyne/klauncherx8
    723 ?        S      0:00 /usr/lib/mozilla/mozilla-bin
    724 ?        S      0:00 /usr/lib/mozilla/mozilla-bin
    725 ?        S      0:00 /usr/lib/mozilla/mozilla-bin
    729 ?        S      0:00 kdeinit: klaptopdaemon -session 11c0a8021400010381450
    730 ?        S      0:00 kteatime -session 11c0a802140001038168018000001282500
    731 ?        S      0:00 kdeinit: kmix -session 11c0a8021400010368648780000000
    735 ?        S      0:00 /usr/lib/mozilla/mozilla-bin
    736 ?        S      0:00 korgac --miniicon korganizer
    745 ?        S      0:00 kalarmd --login
    753 pts/0    S      0:00 bash
    787 ?        S      0:01 emacs
    789 pts/1    S      0:00 bash
    796 ?        S      0:07 kdeinit: konqueror --silent
    800 ?        S      0:00 kdeinit: kio_uiserver    
    801 ?        S      0:02 xmms /files/mp3/00's/Badly Drawn Boy-About a Boy-03-S
    802 ?        S      0:00 xmms /files/mp3/00's/Badly Drawn Boy-About a Boy-03-S
    803 ?        S      0:00 xmms /files/mp3/00's/Badly Drawn Boy-About a Boy-03-S
    804 ?        S      0:00 xmms /files/mp3/00's/Badly Drawn Boy-About a Boy-03-S
    837 ?        S      0:00 xmms /files/mp3/00's/Badly Drawn Boy-About a Boy-03-S
    838 ?        S      0:00 xmms /files/mp3/00's/Badly Drawn Boy-About a Boy-03-S
    860 pts/1    R      0:00 ps U heyne
    
    As you can see, the ps command can give you a lot of interesting information. If you for example want to know what your friend actually does, just replace your login name with her/his name and you see all processe belonging to her/him.

    3.3. Own output format

    If you are bored by the regular output, you could simply change the format. To do so use the formatting characters which are supported by the ps command.
    If you execute the ps command with the 'o' parameter you can tell the ps command what you want to see:
    e.g.
    Odd display with AIX field descriptors:
    $ ps -o "%u : %U : %p : %a"
    RUSER    : USER     :   PID : COMMAND
    heyne    : heyne    :  3363 : bash
    heyne    : heyne    :  3367 : ps -o %u : %U : %p : %a
    

    4. Further reading


    If you need further informations about the ps command just look into the famous man pages of your linux installation.
    $ man ps By Henning Heyne.

    PS:

    ps -af|grep node #Find process using string match
    kill -9 processid #Kill process in high permission

  • 相关阅读:
    浮于文字上方的图片如何设置居中
    grub4dos_BIOS和grub4dos_UEFI编译环境搭建(ubuntu14.04)
    微信小程序开发——开发小技巧集锦
    vue+Better-scroll实现滚动位置保持并对页面切换效果进行优化
    谈谈fork/join实现原理
    ES系列(七):多节点任务的高效分发与收集实现
    JVM系列(五):gc实现概要01
    谈谈stream的运行原理
    ES系列(六):search处理过程实现1框架
    ES系列(五):获取单条数据get处理过程实现
  • 原文地址:https://www.cnblogs.com/limei/p/2017241.html
Copyright © 2011-2022 走看看