PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 18105 mysql 20 0 1453900 156888 8816 S 0.0 4.0 2:16.42 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
4) 如何在批处理模式下运行 top 命令并按照处理时间进行排序
在批处理模式中使用以下 top 命令按照处理时间对结果进行排序。这展示了任务从启动以来已使用的总 CPU 时间。
Fields Management for window 1:Def, whose current sort field is %CPU Navigate with Up/Dn, Right selects for move then or Left commits, 'd' or toggles display, 's' sets sort. Use 'q' or to end! PID = Process IdnsUTS= UTS namespace Inode USER= Effective User NameLXC= LXC container name PR=PriorityRSan= RES Anonymous(KiB) NI = Nice ValueRSfd= RES File-based (KiB) VIRT = Virtual Image(KiB) RSlk = RES Locked(KiB) RES = Resident Size(KiB) RSsh = RES Shared(KiB) SHR = Shared Memory(KiB) CGNAME = Control Group name S= Process StatusNU= Last Used NUMA node %CPU = CPU Usage %MEM = Memory Usage(RES) TIME+ = CPU Time, hundredths COMMAND= Command Name/Line PPID= Parent Process pid UID= Effective User Id RUID= Real User Id RUSER= Real User Name SUID= Saved User Id SUSER= Saved User Name GID= Group Id GROUP= Group Name PGRP= Process Group Id TTY= Controlling Tty TPGID= Tty Process Grp Id SID= Session Id nTH= Number of Threads P= Last Used Cpu(SMP) TIME = CPU Time SWAP= Swapped Size(KiB) CODE = Code Size(KiB) DATA = Data+Stack (KiB) nMaj = Major Page Faults nMin= Minor Page Faults nDRT= Dirty Pages Count WCHAN= Sleeping in Function Flags= Task Flags CGROUPS= Control Groups SUPGIDS= Supp Groups IDs SUPGRPS= Supp Groups Names TGID= Thread Group Id OOMa= OOMEM Adjustment OOMs= OOMEM Score current ENVIRON= Environment vars vMj= Major Faults delta vMn= Minor Faults delta USED= Res+Swap Size(KiB) nsIPC = IPC namespace Inode nsMNT= MNT namespace Inode nsNET= NET namespace Inode nsPID= PID namespace Inode nsUSER= USER namespace Inode
Current Sort Field: N for window 1:Def Select sort field via field letter, type any other key to return a:PID = Process Id b:PPID = Parent Process Pid c:RUSER = Real user name d:UID = User Id e:USER = User Name f:GROUP = Group Name g:TTY = Controlling Tty h:PR = Priority i:NI = Nice value j:P = Last used cpu (SMP) k:%CPU = CPU usage l:TIME = CPU Time m:TIME+ = CPU Time, hundredths * N:%MEM = Memory usage (RES) o:VIRT = Virtual Image (kb) p:SWAP = Swapped size (kb) q:RES = Resident size (kb) r:CODE = Code size (kb) s:DATA = Data+Stack size (kb) t:SHR = Shared Mem size (kb) u:nFLT = Page Fault count v:nDRT = Dirty Pages count w:S = Process Status x:COMMAND = Command name/line y:WCHAN = Sleeping in Function z:Flags = Task Flags Note1: If a selected sort field can't be shown due to screen width or your field order, the '<' and '>' keys will be unavailable until a field within viewable range is chosen. Note2: Field sorting uses internal values, not those in column display. Thus, the TTY & WCHAN fields will violate strict ASCII collating sequence. (shame on you if WCHAN is chosen)