Process Management Learning Notes

Source: Internet
Author: User


    1. First, the state

1. Running or waiting in the running queue for [ready queue]), denoted by the status code R

2. Interrupt status (dormant, blocked, waiting for a condition to form or receive a signal), denoted by the status code S

3. Non-interruptible status (the signal does not wake up and is not operational, the process must wait until there is an interrupt), using the status code D to indicate

4. Zombie State (The process has been terminated, but the process descriptor exists until the parent process calls WAIT4 () after the system call is released), denoted by the status code Z

5. Stop status (Process received Sigstop, SIGSTP, Sigtin, Sigtou signal after stop running run), denoted by the status code T

PS Tool identifies 5 status codes for the process:

D non-interruptible uninterruptible sleep (usually IO)

R run runnable (on run queue)

S Interrupt Sleeping

T stop traced or stopped

Z Zombie a defunct ("zombie") process


<: high-priority process

N: Low-priority process

+: Processes in the foreground process group

L: Multithreaded Process

S: Session Process

II. Inter-process communication (Ipc:inter process communication)

Shared memory

Signal: Signal

Kill-l display of all available signals

1:sighup: Allow a process to reread its configuration file without restarting, and let the new configuration information take effect

2:sigint:ctrl+c: Interrupt a foreground process

9:sigkill: Kill a process (directly forcibly close the process)

15:sigterm: Terminates a process, default signal (frees all resources)

Semaphore: communicates with other processes by marking semaphores

...

Specify to kill a signal (default 15 signal):

Take top as an example

signal Number: Kill 13310
Signal Name: Kill-sigkill
Signal name shorthand: Kill-kill
Kill PID
Killall COMMAND (when multiple processes need to be killed): Killall httpd


Ii. directives

PS:

-e Displays all processes.

-F full format.

-H does not display the caption.

-L long format.

-W wide output.

-F Show more fields

-O Displays the specified field (Ps-o pid,comm,ni)

A shows all processes on the terminal, including the processes of other users.

R displays only the processes that are running.

X shows the process with no control of the terminal.

Examples of common directives:

-elf

-ef

-ef

Data Labels:

User//username

UID//user ID, but output is user name

PID//Process ID

PPID//Parent process ID

C//Percentage of CPU consumed by process

Stime//Process start to present 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

CMD//Command name and parameters

Percentage of CPU%CPU//process occupied

%MEM//Percentage of memory occupied

VSZ//The amount of virtual memory used by the process (KB)

RSS//This process occupies a fixed amount of memory (KB) (number of pages residing in)

STAT//Status of the process

Start//The process is triggered by startup time

Time//When the process actually uses the CPU to run

PRI//Priority

NI//nice Value

The CPU where the PSR//process is running

Pstree: Displays the process tree on the current system

pgrep: get process ID

[[email protected] 2]# pgrep-u root bash
9339

pidof: Find the ID number of its associated process based on the process name

[Email protected] 2]# pidof bash
9339 767

Top

M: Sort based on the size of the resident memory

P: Sort by CPU percent usage

T: Sort by cumulative time


L: Show average load and start time

T: whether to display process and CPU status related information

M: whether memory-related information is displayed

C: Whether to display full command line information

Q: Exit Top

K: Terminate a process


-D: Specify the delay length in seconds

-B: In batch mode, in turn screen mode

-N #: How many screens are displayed in batch mode

Free : View current system memory usage, which shows the remaining and used physical and swap memory in the system, as well as shared memory and buffers used by the core.

Vmstat: System Status View command

[Email protected] 2]# vmstatprocs-----------memory-------------Swap-------io-----system--------CPU-----R B SWPD     Free buff cache si so bi bo in CS us sy ID WA St 3 0 0 3055292 976 528100 0 0 7 1 28 49 0 0 100 0 0


Iv. Adjustment of Nice values

To adjust the nice value of a process that is already started: Renice NI PID

Specify a nice value at startup: Nice-n NI COMMAND

V. Front desk and backstage

Foreground job: Occupy command prompt
Background job: After startup, release the command prompt, and subsequent operations are completed in the background

Front desk--Backstage:
CTRL + Z: Send the work in the foreground to the backstage, add a stop signal, work in the background stop running
Command &: Let commands execute in the background

BG: Let the stop job in the background continue to run
BG [[%]jobid]

Jobs: View all jobs in the background
Job number, different from process number
+: Command will default action for jobs
-: command to assign a second default action to the job

FG: Back-office jobs to the foreground
FG [[%]jobid]


Kill%jobid: Terminate a job

Process Management Learning Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.