1. General description of the order
Man Psps-report a snapshot of the current processes.
The PS command is used to report the process status of the current system. You can break and delete unnecessary programs with the KILL command at any time. The PS command is the most basic and very powerful process view command that can be used to determine which processes are running and running, whether the process is complete, if the process is dead, which processes are consuming too much resources, and so on.
2. Common options
-A: Displays all programs. And-e have the same effect. -E: The effect of this option is the same as specifying the "A" option. -F: Displays Uid,ppip,c and Stime fields. A: Displays all programs under the current terminal, including other users ' programs. U: Displays the status of the program in a user-oriented format. x: Show All Programs, do not differentiate by terminal.
3. Common commands
3.1 PS aux
Ps aux Detailed: Is the BSD format to display User pid %cpu %mem vsz rss tty stat start time command user: The genus Group of the process.  PID : The process ID number of the process.  %CPU: The percentage of cpu resources that the process occupies. %mem: The percentage of physical memory that the process occupies.  VSZ&NBSP: The amount of virtual memory (Kbytes) rss  used by the process;: The number of fixed amounts that the process consumes (Kbytes) TTY : The process is operating on that terminal, if it is not related to the terminal, the display ?, in addition, tty1-tty6 is the machine above the login program, if the pts/0 and so on, it is represented by the network connected to the host computer program. stat: The current state of the program, the main state is:    D : Non-disruptive uninterruptible sleep (usually IO) r : Run runnable. The procedure is currently in operation or may be operational; s : Interrupt sleeping. The program is currently   in sleep, but can be awakened by certain signals (signal) . t : Stop traced or stopped. The program is currently being detected or stopped;    Z&NBSP: Zombie a defunct ("zombie") process. The program should have been terminated, but its parent program can not properly terminate him, resulting in zombie (Xinjiang Corpse) The status of the program start: The process is triggered by the start of time; time&nbSP;: The time that the process actually uses CPU operation. command: The actual command of the program.
3.2 Ps-ef
PS-EF Detailed: Standard format showing the UID of the process PID PPID C stime TTY time Cmduid user ID, but output is the ID of the user name PID process PPID parent Process ID C Percentage of CPU consumed by process stime the process starts to the current time TTY the process runs on that terminal, if it is not related to the terminal, then display? For pts/0, this means that the host process is connected by the network. The name and parameters of the CMD command
3.3 Viewing the process that consumes the highest CPU
PS Aux|head-1;ps aux|grep-v pid|sort-rn-k 3|head
3.4 Viewing the most memory-intensive processes
PS Aux|head-1;ps aux|grep-v pid|sort-rn-k 4|head Explanation: PS aux|head-1: PS aux|grep-v PID: View process sort-rn-k 4|head: number in fourth column Value size in reverse order (default from small to large)
3.5 Viewing a process from a user
Ps-fu Root #root表示用户
3.6 Viewing Zombie processes
On Linux systems: PS-EF | grep defunct #查看命令另外可以使用top命令查看topTasks: 1 running, 94 sleeping, 0 stopped, 0 zombieps-ef | grep defunct | Grep-v grep | Wc-l #统计所有的僵尸进程solaris系统上: A) Determine the zombie process Ps-efo Uid,pid,ppid,pcpu,pmem,vsz,rss,osz,etime,stime,s,comm | grep Z or Ps-ef | grep defunct | MOREB) determine the zombie process start time Ps-efo Uid,pid,ppid,pcpu,pmem,vsz,rss,osz,etime,stime,s,comm | grep 20396 (Process number)
3.7 Viewing process start time and run time
Ps-eo pid,user,lstart,etime,comm,argspid: Process iduser: User lstart: Start time etime: Run time Comm: Command args: Command verbose parameter
3.8 Viewing programs run by a user on a remote host through Ansible management
Cat checkproc.yml----Name:check remote proc hosts:linux remote_user:root gather_facts:false tasks:-NA Me:check proc Shell:ps-ef | Grep-v grep | grep Apache | Wc-l Register:proccount-name:see the Pro fail:msg: "Apache user exist process!" When:pscount.stdout! = "0" Ansible-playbook-i hosts Checkproc.yml
3.9 Delete a program run by a user on a remote host through Ansible management
[email protected] ansible]# Cat kill.sh #!/bin/bashps-ef | Grep-v grep | grep Nxy | awk ' {print $} ' | Xargs kill [[email protected] ansible]# lsansible.cfg hosts Hosts.20170605bak kill.sh roles[[email protected] ansible] # Ansible-i hosts node2-m script-a "/etc/ansible/kill.sh"
This article is from the "where Paobao" blog, please be sure to keep this source http://nxyboy.blog.51cto.com/10511646/1932504
PS of Basic Linux commands