Process Management Commands
First, view user information W
1, w display the meaning of the message
TTY: describes the way users log on , Ttyn: indicates a local terminal logon ;p ts/n indicates a remote terminal login
JCPU: The terminal code to differentiate , the terminal all related Process execution , the CPU time consumed will be displayed here
PCPU:CPU Time spent executing the program
What: actions the user is performing
Load average: shows the Average load level of the system in the last 1, 5, and minutes respectively "generally under 0.8 , we think the system load is light"
From: shows where the user logs on to the system , ": 0" is displayed on behalf of the user from the X Window , opens the Text mode window of the login
Idle: The user is idle time. This is a timer that will be reset once the user performs any action
2. View individual user Information : w user name
Second, check the system process PS
1. Common Options
A: show processes for all users
U: display user name and start time
X: show process without control terminal
E: Show All Processes , including those without control terminal
L: long format display
W: wide line display , can be used to widen the display with multiple W
2,PS commonly used to export the meaning of information
PID: Process number
PPID: process Number of the parent process
TTY: process-initiated terminal
STAT/S: process Current State
#S Sleep State, D non-interruptible sleep state, R Run State , Z Zombie State , T Stop
NI (Nice): process Priority
time: Total CPU elapsed since the process was started
Command/cmd: The command name of the process
User: username
%CPU: percentage of CPU time and total time consumed
%MEM: percentage of total memory consumed and system memory
3."Application Example"
PS View the process that belongs to you
Ps-u or-l View the details of your own process
Ps-le Or-aux See the details of the processes performed by all users , but -aux will see some very intuitive displays , such as %mem,%cpu
"Best Practice:ps-le | grep httpd, of course, you can also view /etc/rc.d/init.d/httpd status by starting the script or Service httpd Status"
Ps-aux--sort Time/pid/uid # processes can be sorted by process execution time, pid,uid , etc.
Ps-uu Sam or Ps-aux | grep sam #查看系统中specified user-executed process
Ps-le | grep init# View specified process information
"Use pstree to view a tree-like process information in the system"
Third, kill the process -kill
1. Why to kill the process
The process is consuming excessive CPU time
The process has shrunk a terminal so that no other foreground process can run
Running too long , but with no expected effect
Produce too much output to screen or disk files
Unable to exit normally
2.
" Close process with process number as parameter"
Kill Process Number : Close process
"If you want to close a set of processes and because this group of processes has a common parent process, close the parent process"
kill-9 Process number : Forcibly closed
KILL-1 Process number : Restart Process
"kill-l will list all the signals."
Xkill: Close the graphics program
Killall [ process name ]: Close all Processes
such as:killall httpd#关闭Apache server,killall close all with httpd Process with the same name
--------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------
" take service name as parameter "
Pgrep Service Name : Find service process number PID
such as: Pgrep httpd can retrieve the PID of all the httpd processes
e.g Kill-1 ' pgrep httpd '
Pkill Process name : Close Process
The attached-/proc directory is stored in memory , and the system details and process information are saved , and the numbers represent the PID of the currently running process
Iv. assigning priority levels
"* Priority value range is ( -20,19) * default startup priority is 0, the lower priority value, the greater the priority"
1 . Nice specifies the priority of program operation
Format nice-n Command
For example Nice-5 Myprogrem
Nice--5/etc/rc.d/init.d/httpd start# priority level is -5
2.renice Change the priority of a running process
Format renice n pid "Note: There is no "-""
For example Renice-30 777
V.nohup command to allow the process to continue execution after the user exits the login
The Nohup command stores the executed data information and error information in the file nohup.out by default
Format: Nohup Program &
Example: Nohup Find/-name init* >/root/find.init.info &
Vi. process Hang-up and recovery
1, Process abort (suspend / pause) and termination
Hang Ctrl + Z
Stop ctrl+c# to see [1]+ Stopped
2.viewing a process that is suspended and running in the background jobs
3. Process Recovery
Revert to the foreground to continue with FG [ the number seen by jobs ] such as: FG 1
Resume to background continue execution Bg[jobs See the number ] such as: BG 1
Seven,top command
Role : process Status Display and Process Control , the default is automatically refreshed once per 3.0 seconds ( dynamic display )
Options: [Use in top software operation ]:
D: Specify the time interval for refresh
C: display the entire command line instead of displaying the command name
U: View the process for a specified user
K: terminate the process in progress
h or?: Get help
R: re-set process priority
S: Change the time interval for refresh
W: writes the current settings to the ~/.TOPRC file
Linux Process Management (second edition)--Process management commands