top

List running processes on the system, in sorted order.
Periodically displays a list of processes on the system in sorted order. The default key for sorting is pid, but other keys can be used instead.

Syntax
      top    [-a | -d | -e | -c mode]
             [-F | -f]
             [-h]
             [-i interval]
             [-l samples]
             [-ncols columns]
             [-o key] [-O skey]
             [-R | -r]
             [-S]
             [-s delay]
             [-n nprocs]
             [-stats keys]
             [-pid processid]
             [-user username]
             [-U username]
             [-u]

Options

Command line option specifications are processed from left to right. Options can be specified more than once. If conflicting options are specified, later specifications override earlier ones. This makes it viable to create a shell alias for top with preferred defaults specified, then override those preferred defaults as desired on the command line.

       -a     Equivalent to -c a.

       -c mode
       Set event counting mode to mode.  The supported modes are:

           a  Accumulative mode. Count events  cumulatively,  starting
              at the launch of top. Calculate CPU usage and CPU time
              since the launch of top.

           d  Delta mode. Count events relative to the previous sample.
              Calculate CPU usage since the previous sample.

           e  Absolute mode. Count events using absolute counters.

           n  Non-event mode (default).  Calculate CPU usage since the
              previous sample.

       -d   Equivalent to -c d.
       -e   Equivalent to -c e.

       -F   Do not calculate statistics on shared libraries, also  known  as
            frameworks.   This substantially reduces the amount of processor
            time top consumes.

       -f   Calculate statistics on shared libraries, also known  as frame-
            works (default).

       -h   Print command line usage information and exit.

       -i interval
Update framework (-f) info every interval samples -l samples Use logging mode and display samples samples, even if standard output is a terminal. 0 is treated as infinity. Rather than redisplaying, output is periodically printed in raw form. -ncols columns Display columns when using logging mode. The default is infinite. The number must be > 0 or an error will occur. -n nprocs Only display up to nprocs processes. nprocs can be specified as the last command line argument without the -n flag preceding it. However, doing so is deprecated command line usage. -O skey Use skey as a secondary key when ordering the process display. See -o for key names (pid is default). -o key Order the process display by sorting on key in descending order. A + or - can be prefixed to the key name to specify ascending or descending order, respectively. Some supported keys (see 'man top' for a full list): command Command name. cpu CPU usage. cpu_me CPU time charged to me by other processes. cpu_others CPU time charged to other processes by me. csw Number of context switches. pid Process ID (default). prt Number of Mach ports. reg Number of memory regions. rprvt Resident private address space size. rshrd Resident shared address space size. rsize Resident memory size. th Number of threads. time Execution time. threads alias: th No. of threads (total/running). uid User ID. username Username. vprvt Private address space size. vsize Total memory size. -R Do not traverse and report the memory object map for each process. This substantially reduces the amount of processor time top consumes. -r Traverse and report the memory object map for each process (default). -S Display information about swap usage and purgeable memory. -s delay Set the delay between updates to delay seconds. The default delay between updates is 1 second. -stats keys Only display the comma separated statistics. See the -o flag for the valid keys. -pid processid Only display processid in top. -U user -user user Only display processes owned by user. Either the username or uid number can be specified. -u This is an alias equivalent to: -o cpu -O time.

Performance vs. Accuracy

Calculating detailed memory statistics is fundamentally resource-intensive. To reduce the cpu usage in top, the -i parameter has been introduced to allow the user to tune this tradeoff. With the default value of 10, framework stats will be updated once every 10 samples. Specifying -i 1 will result in the most accurate display, at the expense of system resources.

Examples

Display processes sorted by CPU usage, updating every 5 seconds:

$ top -ocpu -s 5

Run top in delta mode:

$ top -c d

Run top in event counter mode:

$ top -ce

Show deltas for network and paging activity, updating every 10 seconds:

$ top -d -u -s 10

“Venice is like eating an entire box of chocolate liqueurs at one go” ~ Truman Capote

Related macOS commands

kill - Stop a process from running.
signal(3) - software signal facilities.


 
Copyright © 1999-2024 SS64.com
Some rights reserved