[Linux] The ps command sorts according to different indicators

The ps command is a commonly used process management command in the Linux system. You can use this command to view the process information currently running in the system.

psThe command can sort process information according to different criteria. The common sorting methods are as follows:

  • %cpu: Sort according to the proportion of CPU time occupied by processes, use ps aux --sort=-%cpucan put the process occupying the most CPU time at the front of the list.
  • %mem: Sort according to the proportion of memory occupied by the process. Use ps aux --sort=-%memcan put the process occupying the most memory at the front of the list.
  • start: Sort according to the process start time, use ps aux --sort=-start to put the process with the latest start time at the front of the list.
  • pid: Sort according to the process ID, use ps aux --sort=-pidto put the process with the largest process ID at the front of the list.

In addition, multiple keywords can also be used for combined sorting. For example, you ps aux --sort=-%cpu,%memcan sort by CPU usage first, and then sort by memory usage when the CPU usage is the same.

It should be noted that the ps command may have certain differences in different operating systems, and the specific sorting methods and options may also be slightly different. You can use man psthe command to view specific options and usage.

Guess you like

Origin blog.csdn.net/imliuqun123/article/details/130981943