1
头图

Process view

  • ps aux
    ps is process status , which means process status.
    Parameter information

    • a : all displays the processes used, not only the processes started by the current user
    • u : Output process information in the format of user
    • x : Display the processes under all terminals of the current user
      returned messages

      USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
      root         1  0.0  0.2  44672  3864 ?        Ss   1月15   0:02 /usr/lib/syste
      root         2  0.0  0.0      0     0 ?        S    1月15   0:00 [kthreadd]
      root         4  0.0  0.0      0     0 ?        S<   1月15   0:00 [kworker/0:0H]
      
  • USER The user who started the process
  • PID Process ID
  • %CPU CPU share (%)
  • %MEM Memory occupancy rate (%)
  • VSZ virtual memory (swap space) occupied by 061e43a098cf09
  • RSS occupies the size of the resident memory (physical memory)
  • TTY process is running on which terminal, ? unknown or no terminal required
  • STAT indicates process status

    • S sleep
    • R run
    • Z Zombie
    • < high priority
    • N low priority
    • s parent process
    • + foreground process
  • START Process start time
  • TIME process take to execute
  • COMMAND The command to start the process
  • ps ef
    Parameter information

    • e : Display information about all processes in the system
    • f : full display process information in full format
      Display information
      Basically similar aux
  • top
    Display information

    top - 01:25:39 up  5:25,  4 users,  load average: 0.03, 0.06, 0.07
    Tasks: 101 total,   4 running,  97 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  1.3 us,  1.7 sy,  0.0 ni, 97.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
    KiB Mem :  1882012 total,   404536 free,   199104 used,  1278372 buff/cache
    KiB Swap:        0 total,        0 free,        0 used.  1486184 avail Mem 
    
      PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND   
     1056 root      20   0   51136   1112    772 R  0.7  0.1   2:33.37 rshim        
        1 root      20   0   44672   3864   2444 S  0.0  0.2   0:02.64 systemd 
    • The first line, the task queue information, is the same as the result of the uptime

      System Time: 01:25:39

      Running time: up 5:25

      Currently logged in users: 4 users

      Load balancing: load average: 0.03, 0.06, 0.07 The three numbers represent the load of 1 minute, 5 minutes and 15 minutes respectively

    • second line, task

      Tasks: 101 total, 4 running, 97 sleeping, 0 stopped, 0 zombie total processes: 101 running: 4 sleeping: 97 stopped: 0 zombie processes: 0
    • The third line, the cpu share

      %Cpu(s): 1.3 us, 1.7 sy, 0.0 ni, 97.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
      • us - user space: 1.3%
      • sy - Kernel space (sysctl): 1.7%
      • ni - Processes whose priority has changed (nice): 0.0%
      • id - idle cpu (idol): 97.0%
      • wa - io wait (wait): 0.0%
      • hi - Hard interrupt usage (Hardware IRQ): 0.0%
      • si - Software Interrupts: 0.0%
    • The fourth line, the memory status

      KiB Mem : 1882012 total, 404536 free, 199104 used, 1278372 buff/cache total memory = free memory + used memory + cached memory
    • The fifth line, swap swap partition information

      KiB Swap: 0 total, 0 free, 0 used. 1486184 avail Mem

      linux order to improve the efficiency and speed of reading and writing, the file will be cached in memory, this is part of the cache memory cache memory , even after the end of your program to run this memory will not be released, which leads to your linux system After the program reads and writes files frequently, the available physical memory becomes less. When the physical memory becomes insufficient, it needs to release some space from the physical memory. This part of the released space information will be temporarily reserved in the swap space. Wait until the program When this part of data is needed for operation Swap partition to the memory, so when the Swap used changes frequently, it means that the physical memory of the system is not enough at this time.

      • The sixth line, the meaning of the field is basically similar ps aux
        top -p process pid can only see the process information pid

    process control

    Process priority control

    nice -n 10 XXX : nice xxx process is started to set its priority to 10. The range of this value is (-20~19), the smaller the value, the higher the priority.
    renice -n -20 17265 : The pid = 17265 priority of a process of re-setting -20

    Process job control

    ./xxx.sh & The process to be started, running in the background.
    jobs can view the processes running in the background.

    [2]+ Running nice -n 10 ./minio server /data/minio.data/ &

    fg 2 : fg + jobs number brings the process to the foreground.
    ctrl + z : Change the process to stopped state.
    bg 2 : bg + jobs number Run this program in the background.

    Service Management Tools

    service and systemctl are Linux manages services.

  • service actually goes to the /etc/init.d directory to execute related programs

    service redis start
    等同于
    /etc/init.d/redis start
    

    service xxx start Start service

    service xxx stop shutdown service

    service xxx restart restart service

    service xxx status View service status

  • systemctl is Linux latest initialize the system init , the role is to improve the system's boot speed, systemctl also compatible service command that systemctl also to init.d directory continue implementation of relevant procedures.

    systemctl start xxx Start the service

    systemctl stop xxx shutdown service

    systemctl restart xxx restart service

    systemctl status xxx View service status

    systemctl reload xxx reload service

    systemctl enable xxx boot service

    systemctl disable xxx Start and stop service


eacape
205 声望8 粉丝

JAVA 攻城狮