Linux Process Management

Source: Internet
Author: User
Tags cpu usage

When we use any operating system will open some applications, then open the program will open a process, we use the Windows system, sometimes open a QQ, while opening a game, you can also open the music playback software, Too many open programs will consume a lot of memory and CPU is the system sometimes feel very lag, then under Linux How to manage the process, and then share with you under the Linux system Linux process management.


  1. Static management process
    PS-E listing information about all processes

    PID TTY Time CMD

    Process 1th is the parent process for all processes Init

    Pstree list processes in a tree-like form

    Ps-ef
    UID PID PPID C stime TTY time CMD
    Process Owner
    The temporary execution exit does not occupy the state


    PS AU
    USER PID%cpu%MEM VSZ RSS TTY STAT START

    %CPU CPU Usage
    %MEM Memory Utilization
    VSZ Virtual Memory
    RSS Memory Pages
    The process when start starts

    PS Axo Pid,pri,nice,%cpu,%mem,command | grep vsftpd

    Ps-p PID

    PS U-p 6917

    -e/-a All Processes
    A All TTY (Bsd-style)
    F Full Format display
    Ppid Show Parent Process

    Ps-u root to see which processes are open for a specified user

    PS A
    PID TTY STAT Time COMMAND

    1. Process ID
    2. Console
    3. Process status
    Status of the STAT process:
    R Running Processes
    S can interrupt the hibernation process
    T Stop/Pause process
    D Non-disruptive process
    Z Zombie Zombie Process
    X exit Status
    s and child processes
    L Lock memory Page memory
    N a process with a lower priority level
    < high-priority processes

    4. CPU Time consumption
    5. Name of the process




    Ps-ef

    PS aux

    PS Axo


    Netstat-tulnp

    T: TCP-based protocol
    U: UDP-based protocol
    L:listening Listening If listening indicates that the service is running
    N: Do not do domain name resolution
    P: Process Name

    lsof-i:80 See if Port 80 is listening

    Pidof vsftpd View the PID of the process (only the PID of the running service can be viewed)

    Process dynamic management
    Uptime
    11:30:15 up 2:37, 4 users, Load average:1.02, 1.01, 0.95

    How long does the current system time open 4 users average load per 1, 5, 15 minutes


    Top
    %us User Space Utilization
    %sy kernel Space

    PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND
    1.pid
    2. The owner of the process
    3.PRI Priority
    4.nice value
    5.6
    7.SHR shared Memory The main mechanism for different inter-process access
    8.S process Status
    9.CPU usage Rate
    10. Memory utilization
    11
    12

    Top
    P CPU
    M Men
    K-PID
    Z with color display
    Q exit

    Top-u redhat Dynamic View Redhat user information
    Top-p 1 view specified PID information



    /proc
    Cat/proc/meminfo Viewing memory status
    Cat/proc/cpuinfo Viewing CPU Details

    Route forwarding

    Temporary
    Echo 1 >/proc/sys/net/ipv4/ip_forward

    Permanent
    echo "Echo 1 >/proc/sys/net/ipv4/ip_forward" >>/etc/rc.local

    Configuration file for Environment variables
    ~/.BASHRC ~/.BASH_PROFILE/ETC/PROFILE/ETC/BASHRC

    Vim/etc/sysctl.conf
    Net.ipv4.ip_forward = 1

    Sysctl-p make current configuration effective immediately

    echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all Place Ping
    ----------------------------------------------------------------
    Process Management (Kill)

    Kill [Signal] PID

    Pidof VSFTPD
    6917

    Kill 6917

    Kill-15 15185

    Kill-9 15185 Mandatory

    Signal
    Man 7 signal = Kill-l

    1 Reload Reload profile does not affect business
    2 CTRL + C Force interrupt
    9 Forced Kill process
    15 Normal Kill Process
    17 Pause
    18 Recovery

    Process scheduling (pre-background switchover)

    Process foreground:
    Consumes the current shell when the shell shuts down the process ends

    Background
    Xeyes & End When the shell closes the process

    CTRL + Z puts the foreground running process in the background and is in a stopped state

    CTRL + C kills the current process force termination

    Nohup Xeyes & Keep the process running in the background without occupying the current shell


    Pkill httpd Kill process by program name

    ------------------------------------------------------------------
    Front and rear switch of process

    View Job number
    Jobs
    [1]-Running Xeyes &
    [2]+ Running Xeyes &

    A:1, 2 indicates the job number
    b:+ the current process
    -Represents the previous process of the current process
    C: Status

    Put the background process in the foreground
    FG%1

    CTRL Z---> Background and terminate the foreground process

    Keep the background paused process in the background and continue running
    BG%1

    Kill%1 kills the process where the first job is located
    ---------------------------------------------------------------------
    Process Priority tuning

    Process priority cannot be adjusted directly to the nice value, and the value of the PRI is affected by the Nice value adjustment

    Kindness Value Range
    -20 (maximum priority) to 19 (minimum priority)

    You can specify a priority when the process is turned on
    PS Axo Pid,nice,pri,command | grep vsftpd
    15220 0 19/USR/SBIN/VSFTPD

    Open a process the default nice value is 0 priority 19

    The greater the Nice value----the PRI takes precedence (smaller)

    Specifies the priority of its operation when the service is opened
    Nice-n 1 Xeyes Nice--->1
    17483 1 Xeyes

    Nice-n-1 Firefox & nice--->-1

    Adjustments that have been defined for the priority level

    Renice-5 17803

    Note: The number after Renice is the one you want to end up with -5 (Nice)



Linux Process Management

Related Article

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.