Linux (Radhat) Basic Learning-process management

Source: Internet
Author: User
Tags arithmetic terminates

1. Process definition
进程(process)是一个具有一定独立功能的程序关于某个数据集合的一次运行活动。它是操作系统动态执行的基本单元,在传统的操作系统中,进程既是基本的分配单元,也是基本的执行单元。
2. Process View

1. Graphical view

gnome-system-monitor


2. Command line view

ps命令ps        ##只显示当前teminel进程信息        x|-A       ##所有进程        -d        ##显示除了当前shell的所有进程        f           ##显示进程从属关系        e         ##显示进程调用环境工具的详细信息(系统资源调用)        l          ##长列表显示当前环境的进程的详细信息        u         ##显示进程的用户信息        -a      ##显示shell前台运行命令的进程,但不保函shell环境本身        a        ##与当前环境有关的所有进程,(当前环境 != teminel 一个环境可以开多个teminel)        x        ##列出系统中所有运行,包含tty(输出设备)


View process Common PS command combinations

    ps aux    ##显示所有进程并显示进程用户    ps ef        ##显示进程详细信息并显示从属关系    ps ax       ##显示当前系统中的所有进程

Show process-specific information

ps ax -o %cpu,%mem,user,group,comm,nice,pid,stat      ##指定显示进程的某些信息%cpu       ##显示进程cpu负载%mem    ##显示进程内存负载user        ##进程用户group    ##进程组comm    ##进程名称nice       ##进程优先级pid     ##进程的idstat      ##进程状态


The information displayed in stat:

S    ##进程状态s    ##顶级进程R   ##T   ##进程休眠l    ##内存中有锁定空间N   ##优先级低<   ##优先级高+   ##前台运行

Give me another chestnut:

ps ax --sort=[+/-%cpu] [+/-%mem] -o %cpu,comm,pid   ##按照进程信息排序                    + 正序/升序       - 倒序/降序%cpu           ##cpu负载排序%mem        ##内存负载

3. Process priority

1. Priority scope of the process

-20~19

2. Priority view

ps ax -o pid,nice,comm

3. Specify a priority to open the process

nice -n 优先级数字 进程名称nice -n -5 vim &              ##开启vim并且指定程序优先级为-5 &符号表示在后台打开

4. Change the process priority
Format:

reince -n 优先级数字 进程pid

Chestnuts:
PS A-o Pid,nice,comm
Renice-n 2 31672 # #改变31672进程的优先级为2
PS A-o Pid,nice,comm

4. Front and back calls to processes in the environment
comm &            ##让命令直接在后台运行jobs                   ##查看被打入环境后台的进程,数字后面的“+”“-”表示fg不输入后台程序代表数字时调回前台的优先级,+最高,-次之,没有符号优先级最低ctrl+z                 ##把占用终端的进程打入后台fg jobsnum       ##把后台进程调回前台bg jobsnum      ##把后台暂停的进程运行
5. Process Signal

Common signal levels

1         ##进程重新加载配置,不必重启进程,进程不变。2         ##删除进程在内存中的数据,3         ##删除鼠标在内存中的数据9         ##强行结束单个进程(不能被阻塞)15      ##正常关闭进程     (可能会被阻塞)   18      ##运行暂停的进程19      ##暂停某个进程     (不能被阻塞)20      ##暂停某个进程    (可以被阻塞)

Man 7 Signal # #查看信号详细信息

kill -信号 进程pidkillall -信号 进程名字pkill   -u student -信号  

As an example:

 SIGHUP terminates the process terminal line hangs SIGINT terminates process Sigquit establishes core file termination process and generates core file Sigill build C Ore file illegal directive sigtrap establish core file Tracking self trap sigbus build core file Bus error SIGSEGV build core file segment illegal error SIGFPE Build core file floating point exception Sigiot build core file perform I/O self-trap sigkill terminate process kill process sigpipe terminate process to a A pipeline that does not read a process writes data sigalarm terminates a process timer to a stop signal that sigterm terminates the process software termination signal sigstop stop process non-terminal SIGTSTP Stop signal from process terminal Sigcont ignore signal continue to execute a stopped process Sigurg ignore signal I/O emergency signal Sigio ignore signal Descriptors can be i/osigchld ignored signals when a child process stops or exits notifies the parent process Sigttou stop process background process write Terminal Sigttin stop process Background process read Terminal SIGXGPU terminate process CPU time-out SIGXFSZ End process file length sigwinch ignore signal window size change Sigpro F Terminate process Statistics distribution graph with timer to time SIGUSR1 terminate process user-defined signal 1SIGUSR2 terminate process user-defined signal 2SIGVTALRM terminate process Virtual Timer to 

1) SIGHUP
This signal is issued at the end of the user terminal connection (normal or abnormal), usually in the terminal control
At the end of the process, notify each job in the same session, and the control terminal
is no longer associated.

2) SIGINT
program termination (interrupt) signal, which is emitted when the user types Intr characters (usually ctrl-c)

3) Sigquit
Sigquit and SIGINT are similar, but are controlled by the Quit character (usually ctrl). Process in response to receipt
Sigquit exit will produce a core file, in this sense similar to a program error letter
No..

4) Sigill
An illegal instruction was executed. This is usually due to an error in the executable file itself or an attempt to execute
Data segment. This signal can also be generated when a stack overflows.

5) SIGTRAP
Generated by a breakpoint instruction or other trap instruction. Used by debugger.

6) SIGABRT
Generated when the program itself finds an error and calls abort.

7) Sigiot
The PDP-11 is generated by the IoT instructions on the other machines and the SIGABRT.

8) Sigbus
Illegal address, including memory address alignment (alignment) error. Eg: access to a four word length
Integer, but its address is not a multiple of 4.

9) SIGFPE
Emitted when a fatal arithmetic operation error occurs. Includes not only floating-point arithmetic errors, but also overflow
The sum of the divisor is 0 and all other arithmetic errors.

) SIGKILL
Used to immediately end the run of the program. This signal cannot be blocked, processed and ignored.

SIGUSR1 left for users to use

11)
SIGSEGV attempts to access memory that is not allocated to itself, or attempts to write data to a memory address that does not have write permissions.

SIGUSR2 left for users to use

Sigpipe Broken Pipe

SIGALRM)
A clock timing signal that calculates the actual time or clock time. The alarm function uses the
Signal.

SIGTERM)
Program end (terminate) signal, unlike Sigkill, the signal can be blocked and
Processing. Usually used to ask the program to exit normally. The shell command kill default produces this
A signal.

SIGCHLD)
The parent process receives this signal at the end of the child process.

) Sigcont
Let a stop (stopped) process continue execution. This signal cannot be blocked. can be used
A handler that allows the program to complete a specific application when the stopped state changes to continue execution.
Job. For example, to re-display the prompt

SIGSTOP)
Stop (stopped) the execution of the process. Notice the difference between it and terminate and interrupt:
The process is not over yet, just pausing execution. This signal cannot be blocked, processed or ignored.

SIGTSTP)
Stops the process from running, but the signal can be processed and ignored. When a user types Susp characters
(usually ctrl-z) sends this signal

) Sigttin
When a background job wants to read data from a user terminal, all processes in that job receive Sigttin
Signal. By default, these processes stop executing.

Sigttou)
Similar to Sigttin, but received when writing a terminal (or modifying terminal mode).

Sigurg)
When there is "emergency" data or Out-of-band data arrives at the socket.

) sigxcpu
CPU time resource limit exceeded. This limit can be read by Getrlimit/setrlimit/
Change

SIGXFSZ)
exceeds the file size resource limit.

SIGVTALRM)
Virtual clock signal. is similar to SIGALRM, but calculates the CPU time that is consumed by the process.

SIGPROF)
Similar to SIGALRM/SIGVTALRM, but includes the CPU time used by the process and the system call
Time.

Sigwinch)
emitted when the window size changes.

) SIGIO
The file descriptor is ready to start the input/output operation.

SIGPWR)
Power failure

There are two signals to stop a process: Sigterm and Sigkill. Sigterm is friendly and the process captures the signal and shuts down the program according to your needs. Before you close the program, you can end the open record file and complete the task you are doing. In some cases, if the process is working and cannot be interrupted, the process can ignore the sigterm signal.

For Sigkill signals, the process cannot be ignored. This is a "I don't care what you are doing, stop immediately" signal. If you send a sigkill signal to the process, Linux will stop the process there

6.top command
top     ##监控系统负载工具        s   : 修改进程刷新间隔时间        m   : 根据内存占有率进行排序        c   : 根据 cpu 占有率进行排序        u   : 后面输入用户名 , 用来查看该用户发起的所有进程        k   : 后面跟要作用的进程 pid, 和发起的信号用来给某个进程发起一信号        q   : 退出进程查看界面        h   : 显示 top 命令的帮助

Linux (Radhat) Basic learning-process 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.