2016-10-5 Linux Basic Learning-process and job management

Source: Internet
Author: User
Tags semaphore terminates

Process and Job Management

Uninterruptible sleep: Non-disruptive sleeping
Interruptible sleep: Sleeps can be interrupted

Cow:copy on write when copying

VSZ: Virtual Memory Set
RSS: Resident Memory Set

100-139: Users can control
Nice value: Elegant
-20 ~-19
100 ~ 139
Normal users can only adjust the nice value of the process
Super User Adjustable Height
0-99: Kernel tuning

Under the/proc file, you can see many process numbers
Init: The process number can only be 1, the first process

Large o Standard
O (1)
O (N)
O (LOGN)
O (n^2)
O (2^n)

Classification of processes:
Terminal-related processes
Regardless of the terminal, the process

Process Status:
P: Non-disruptive sleep
R: Run or ready
S: Sleeps can be interrupted
T: Stop
Z: Zombie
B: Blocking

<: high-priority process
N: Low-priority process
+: Processes in the foreground process group
L: Multithreaded Process
S: Session process first Process

[Email protected] ~]#PS aux | head
USER PID%cpu%MEM VSZ RSS TTY STAT START time COMMAND
Root 1 0.0 0.1 2828 1404? Ss 02:27 0:01/sbin/init
Root 2 0.0 0.0 0 0? S 02:27 0:00 [Kthreadd]
Root 3 0.0 0.0 0 0? S 02:27 0:00 [migration/0]
Root 4 0.0 0.0 0 0? S 02:27 0:00 [ksoftirqd/0]
Root 5 0.0 0.0 0 0? S 02:27 0:00 [watchdog/0]
Root 6 0.0 0.0 0 0? S 02:27 0:00 [events/0]
Root 7 0.0 0.0 0 0? S 02:27 0:00 [Cpuset]
Root 8 0.0 0.0 0 0? S 02:27 0:00 [Khelper]
Root 9 0.0 0.0 0 0? S 02:27 0:00 [Netns]

**command Plus [] is the kernel process

PS: Specialized viewing process
Two different styles:
SYSV Style:-
BSD Style:

Common options
A: Show BSD style, display the process related to terminal
U
X: Display is not related to the terminal process

-F: Full style
-E: Show All threads (represents-a)
-L: Long format (pri denotes priority, ni denotes nice value)
-O: Specify properties

[Email protected] ~]# Ps-el | Head
Priority level
F S UID PID PPID C PRI NI ADDR SZ Wchan TTY time CMD
4 S 0 1 0 0 80 0-707-? 00:00:01 Init
1 S 0 2 0 0 80 0-0-? 00:00:00 Kthreadd
1 S 0 3 2 0-40--0-? 00:00:00 migration/0
1 S 0 4 2 0 80 0-0-? 00:00:00 ksoftirqd/0
5 S 0 5 2 0-40--0-? 00:00:00 watchdog/0
1 S 0 6 2 0 80 0-0-? 00:00:00 events/0
1 S 0 7 2 0 80 0-0-? 00:00:00 Cpuset
1 S 0 8 2 0 80 0-0-? 00:00:00 Khelper
1 S 0 9 2 0 80 0-0-? 00:00:00 Netns


!!!!!!!!! Find common uses for a process!!!!!!!
[[Email protected] ~]# PS aux | grep "Bash"
Root 1767 0.0 0.1 7844 1620 tty1 ss+ 02:28 0:00-bash
Root 1790 0.0 0.1 6700 1616 pts/0 Ss 02:29 0:00-bash
Root 2692 0.0 0.0 5936 720 pts/0 d+ 05:35 0:00 grep bash

Pstree: Displays the process tree of the current system


Pgrep: Finding process numbers that match certain characteristics in grep style
-U: Specifies that a user is the owner of a process
eg
[[email protected] ~]# pgrep-u root bash
1767
1790

PIDOF: Find the ID number of its related process according to the program name


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 time 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

Options:
-D #: Specify the time delay, in seconds
-B: Turn screen display, batch mode
-N #: In batch mode, display a total of several times screen

inter-process communication(Ipc:inter Process Communication)
Shared memory
Signal: Signal
Semaphore: Semaphore

Important signals under the kill-l:
1:sighup allows a process to reread its configuration file without restarting, and to have the new configuration information take effect
2:sigint Terminal a process =ctrl+c
9:sigkill kills a process
15:sigterm terminates a process, the default signal

Specify a signal:
Signal Number: Kill-l
Signal Name: Kill-sigkill
Signal name shorthand: Kill-kill

Kill PID: Terminates the specified process number
Kill command: All processes that contain this command will be killed

Adjust nice values
To adjust the nice value of a process that has already started
renice Nice value PID

Specify a nice value at startup:
nice-n NI Command

[Email protected] ~]# PS Axo Pid,nice,command | Head
PID NI COMMAND

7 0 [Cpuset]
8 0 [Khelper]
9 0 [Netns]
[Email protected] ~]# renice 3 8 The nice value of the ———— tuning process with PID 8 is 3
8:old priority 0, new Priority 3
[Email protected] ~]# PS Axo Pid,nice,command | Head
PID NI COMMAND

7 0 [Cpuset]
8 3 [Khelper]
9 0 [Netns]
650) this.width=650; "style=" width:505px;height:500px; "src=" http://s3.51cto.com/wyfs02/M00/88/62/ Wkiom1fz5mxtucteaabuv92vfjq390.png "title=" 2016-10-05_002657.png "height=" "hspace=" 0 "vspace=" 0 "width=" 505 " Border= "0" alt= "wkiom1fz5mxtucteaabuv92vfjq390.png"/>

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

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

Front desk--Backstage:
CTRL + Z to send the front desk work backstage
Command & let commands take place in the background

BG: Keep A background stop job running (in the background)
BG [[%]job-id] Job number

FG: Returning background jobs to the foreground
FG [[%]job-id] Job number

----% can be saved
----If the background process is to be killed, the% cannot be saved
Kill%job-id

Vmstat: System Status View Command
# with a number, specify to refresh every few seconds, dynamic display
# # with two numbers, the first one is displayed every few seconds, the second one is refreshed several times

Uptime
Top the first line of content

cat/proc/meminfo: Memory-related information


cat/proc/# Process Number/maps: Process information

This article is from the "11160930" blog, please be sure to keep this source http://11170930.blog.51cto.com/11160930/1858773

2016-10-5 Linux Basic Learning-process and job management

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.