* Add documentation for the batch and lastcpu keywords.
[dragonfly.git] / bin / ps / ps.1
1 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)ps.1        8.3 (Berkeley) 4/18/94
33 .\" $FreeBSD: src/bin/ps/ps.1,v 1.24.2.7 2002/06/20 22:43:33 charnier Exp $
34 .\" $DragonFly: src/bin/ps/ps.1,v 1.9 2006/04/06 17:26:54 swildner Exp $
35 .\"
36 .Dd April 6, 2006
37 .Dt PS 1
38 .Os
39 .Sh NAME
40 .Nm ps
41 .Nd process status
42 .Sh SYNOPSIS
43 .Nm
44 .Op Fl aCcefhjlmrSTuvwxyY
45 .Op Fl M Ar core
46 .Op Fl N Ar system
47 .Op Fl O Ar fmt
48 .Op Fl o Ar fmt
49 .Op Fl p Ar pid
50 .Op Fl t Ar tty
51 .Op Fl U Ar username
52 .Nm
53 .Op Fl L
54 .Sh DESCRIPTION
55 The
56 .Nm
57 utility
58 displays a header line followed by lines containing information about your
59 processes that have controlling terminals.
60 This information is sorted by controlling terminal, then by process ID.
61 .Pp
62 The information displayed is selected based on a set of keywords (see the
63 .Fl L
64 .Fl O
65 and
66 .Fl o
67 options).
68 The default output format includes, for each process, the process' ID,
69 controlling terminal, CPU time (including both user and system time),
70 state, and associated command.
71 .Pp
72 The process file system (see
73 .Xr procfs 5 )
74 should be mounted when
75 .Nm
76 is executed, otherwise not all information will be available.
77 .Pp
78 The options are as follows:
79 .Bl -tag -width indent
80 .It Fl a
81 Display information about other users' processes as well as your own.
82 This can be disabled by setting the
83 .Va kern.ps_showallprocs
84 sysctl to zero.
85 .It Fl c
86 Change the ``command'' column output to just contain the executable name,
87 rather than the full command line.
88 .It Fl C
89 Change the way the CPU percentage is calculated by using a ``raw''
90 CPU calculation that ignores ``resident'' time (this normally has
91 no effect).
92 .It Fl e
93 Display the environment as well.
94 .It Fl f
95 Show commandline and environment information about swapped out processes.
96 This option is honored only if the uid of the user is 0.
97 .It Fl h
98 Repeat the information header as often as necessary to guarantee one
99 header per page of information.
100 .It Fl j
101 Print information associated with the following keywords:
102 user, pid, ppid, pgid, sess, jobc, state, tt, time and command.
103 .It Fl L
104 List the set of available keywords.
105 .It Fl l
106 Display information associated with the following keywords:
107 uid, pid, ppid, cpu, pri, nice, vsz, rss, wchan, state, tt, time
108 and command.
109 .It Fl M
110 Extract values associated with the name list from the specified core
111 instead of the default
112 .Pa /dev/kmem .
113 .It Fl m
114 Sort by memory usage, instead of by process ID.
115 .It Fl N
116 Extract the name list from the specified system instead of the default
117 .Pa /kernel .
118 .It Fl O
119 Add the information associated with the space or comma separated list
120 of keywords specified, after the process ID,
121 in the default information
122 display.
123 Keywords may be appended with an equals (``='') sign and a string.
124 This causes the printed header to use the specified string instead of
125 the standard header.
126 .It Fl o
127 Display information associated with the space or comma separated list
128 of keywords specified.
129 Keywords may be appended with an equals (``='') sign and a string.
130 This causes the printed header to use the specified string instead of
131 the standard header.
132 .It Fl p
133 Display information associated with the specified process ID.
134 .It Fl r
135 Sort by current CPU usage, instead of by process ID.
136 .It Fl S
137 Change the way the process time is calculated by summing all exited
138 children to their parent process.
139 .It Fl T
140 Display information about processes attached to the device associated
141 with the standard input.
142 .It Fl t
143 Display information about processes attached to the specified terminal
144 device.
145 .It Fl U
146 Display the processes belonging to the specified
147 .Ar username .
148 .It Fl u
149 Display information associated with the following keywords:
150 user, pid, %cpu, %mem, vsz, rss, tt, state, start, time and command.
151 The
152 .Fl u
153 option implies the
154 .Fl r
155 option.
156 .It Fl v
157 Display information associated with the following keywords:
158 pid, state, time, sl, re, pagein, vsz, rss, lim, tsiz,
159 %cpu, %mem and command.
160 The
161 .Fl v
162 option implies the
163 .Fl m
164 option.
165 .It Fl w
166 Use 132 columns to display information, instead of the default which
167 is your window size.
168 If the
169 .Fl w
170 option is specified more than once,
171 .Nm
172 will use as many columns as necessary without regard for your window size.
173 .It Fl x
174 Display information about processes without controlling terminals.
175 .It Fl y
176 Display information associated with the following keywords:
177 uid, pid, ppid, cpu, pri, iac, nice, wchan, state, tt, time, and command.
178 Sort by iac (interactivity measure).
179 .It Fl Y
180 Sort by iac (interactivity measure).
181 .El
182 .Pp
183 A complete list of the available keywords are listed below.
184 Some of these keywords are further specified as follows:
185 .Bl -tag -width indent
186 .It %cpu
187 The CPU utilization of the process; this is a decaying average over up to
188 a minute of previous (real) time.
189 Since the time base over which this is computed varies (since processes may
190 be very young) it is possible for the sum of all
191 .Tn \&%CPU
192 fields to exceed 100%.
193 .It %mem
194 The percentage of real memory used by this process.
195 .It flags
196 The flags associated with the process as in
197 the include file
198 .In sys/proc.h :
199 .Bl -column P_BREAKTSLEEP 0x10000000
200 .It Dv "P_ADVLOCK" Ta No "0x00001       Process may hold a POSIX advisory lock"
201 .It Dv "P_CONTROLT" Ta No "0x00002      Has a controlling terminal"
202 .It Dv "P_SWAPPEDOUT" Ta No "0x00004    Swapped out of memory"
203 .It Dv "P_BREAKTSLEEP" Ta No "0x00008   Event pending, break tsleep on sigcont"
204 .It Dv "P_PPWAIT" Ta No "0x00010        Parent is waiting for child to exec/exit"
205 .It Dv "P_PROFIL" Ta No "0x00020        Has started profiling"
206 .It Dv "P_SELECT" Ta No "0x00040        Selecting; wakeup/waiting danger"
207 .It Dv "P_SINTR" Ta No "0x00080         Sleep is interruptible"
208 .It Dv "P_SUGID" Ta No "0x00100         Had set id privileges since last exec"
209 .It Dv "P_SYSTEM" Ta No "0x00200        System proc: no sigs, stats or swapping"
210 .It Dv "P_STOPPED" Ta No "0x00400       SIGSTOP status"
211 .It Dv "P_TRACED" Ta No "0x00800        Debugged process being traced"
212 .It Dv "P_WAITED" Ta No "0x01000        SIGSTOP status was returned by wait3/4"
213 .It Dv "P_WEXIT" Ta No "0x02000         Working on exiting"
214 .It Dv "P_EXEC" Ta No "0x04000          Process called exec"
215 .It Dv "P_UPCALLPEND" Ta No "0x20000    An upcall is pending"
216 .It Dv "P_SWAPWAIT" Ta No "0x40000      Waiting for a swapin"
217 .It Dv "P_ZOMBIE" Ta No "0x80000        Now in a zombied state"
218 .It Dv "P_ONRUNQ" Ta No "0x100000       On a user scheduling run queue"
219 .It Dv "P_KTHREADP" Ta No "0x200000     Process is really a kernel thread"
220 .It Dv "P_IDLESWAP" Ta No "0x400000     Swapout was due to idleswap, not load"
221 .It Dv "P_DEADLKTREAT" Ta No "0x800000  Lock aquisition - deadlock treatment"
222 .It Dv "P_JAILED" Ta No "0x1000000      Process is in jail"
223 .It Dv "P_OLDMASK" Ta No "0x2000000     Need to restore mask before pause"
224 .It Dv "P_ALTSTACK" Ta No "0x4000000    have alternate signal stack"
225 .It Dv "P_INEXEC" Ta No "0x8000000      Process is in execve()"
226 .It Dv "P_PASSIVE_ACQ" Ta No "0x10000000        Passive acquire cpu (see kern_switch)"
227 .It Dv "P_UPCALLWAIT" Ta No "0x20000000 Wait for upcall or signal"
228 .El
229 .It lim
230 The soft limit on memory used, specified via a call to
231 .Xr setrlimit 2 .
232 .It lstart
233 The exact time the command started, using the ``%c'' format described in
234 .Xr strftime 3 .
235 .It nice
236 The process scheduling increment (see
237 .Xr setpriority 2 ) .
238 .It rss
239 the real memory (resident set) size of the process (in 1024 byte units).
240 .It start
241 The time the command started.
242 If the command started less than 24 hours ago, the start time is
243 displayed using the ``%l:ps.1p'' format described in
244 .Xr strftime 3 .
245 If the command started less than 7 days ago, the start time is
246 displayed using the ``%a6.15p'' format.
247 Otherwise, the start time is displayed using the ``%e%b%y'' format.
248 .It state
249 The state is given by a sequence of letters, for example,
250 .Dq Tn RWNA .
251 The first letter indicates the run state of the process:
252 .Pp
253 .Bl -tag -width indent -compact
254 .It D
255 Marks a process in disk (or other short term, uninterruptible) wait.
256 .It I
257 Marks a process that is idle (sleeping for longer than about 20 seconds).
258 .It J
259 Marks a process which is in
260 .Xr jail 2 .
261 The hostname of the prison can be found in
262 .Sq Li /proc/<pid>/status .
263 .It R
264 Marks a runnable process.
265 .It S
266 Marks a process that is sleeping for less than about 20 seconds.
267 .It T
268 Marks a stopped process.
269 .It Z
270 Marks a dead process (a ``zombie'').
271 .El
272 .Pp
273 Additional characters after these, if any, indicate additional state
274 information:
275 .Pp
276 .Bl -tag -width indent -compact
277 .It +
278 The process is in the foreground process group of its control terminal.
279 .It <
280 The process has raised CPU scheduling priority.
281 .It >
282 The process has specified a soft limit on memory requirements and is
283 currently exceeding that limit; such a process is (necessarily) not
284 swapped.
285 .It A
286 the process has asked for random page replacement
287 .Pf ( Dv MADV_RANDOM ,
288 from
289 .Xr madvise 2 ,
290 for example,
291 .Xr lisp 1
292 in a garbage collect).
293 .It E
294 The process is trying to exit.
295 .It L
296 The process has pages locked in core (for example, for raw
297 .Tn I/O ) .
298 .It M
299 On SMP systems indicates a process or thread which is
300 .Em not
301 holding the MP lock (the Big Giant Lock).
302 .It N
303 The process has reduced CPU scheduling priority (see
304 .Xr setpriority 2 ) .
305 .It S
306 The process has asked for FIFO page replacement
307 .Pf ( Dv MADV_SEQUENTIAL ,
308 from
309 .Xr madvise 2 ,
310 for example, a large image processing program using virtual memory to
311 sequentially address voluminous data).
312 .It s
313 The process is a session leader.
314 .It V
315 The process is suspended during a
316 .Xr vfork .
317 .It W
318 The process is swapped out.
319 .It X
320 The process is being traced or debugged.
321 .El
322 .It tt
323 An abbreviation for the pathname of the controlling terminal, if any.
324 The abbreviation consists of the three letters following
325 .Pa /dev/tty ,
326 or, for the console, ``con''.
327 This is followed by a ``-'' if the process can no longer reach that
328 controlling terminal (i.e., it has been revoked).
329 .It wchan
330 The event (an address in the system) on which a process waits.
331 When printed numerically, the initial part of the address is
332 trimmed off and the result is printed in hex, for example, 0x80324000 prints
333 as 324000.
334 .El
335 .Pp
336 When printing using the command keyword, a process that has exited and
337 has a parent that has not yet waited for the process (in other words, a zombie)
338 is listed as ``<defunct>'', and a process which is blocked while trying
339 to exit is listed as ``<exiting>''.
340 The
341 .Nm
342 utility
343 makes an educated guess as to the file name and arguments given when the
344 process was created by examining memory or the swap area.
345 The method is inherently somewhat unreliable and in any event a process
346 is entitled to destroy this information, so the names cannot be depended
347 on too much.
348 The ucomm (accounting) keyword can, however, be depended on.
349 .Sh KEYWORDS
350 The following is a complete list of the available keywords and their
351 meanings.
352 Several of them have aliases (keywords which are synonyms).
353 .Pp
354 .Bl -tag -width ".Cm sigignore" -compact
355 .It Cm %cpu
356 percentage CPU usage (alias
357 .Cm pcpu )
358 .It Cm %mem
359 percentage memory usage (alias
360 .Cm pmem )
361 .It Cm acflag
362 accounting flag (alias
363 .Cm acflg )
364 .It Cm batch
365 batchness of the process (higher numbers mean less interactivity)
366 .It Cm command
367 command and arguments
368 .It Cm cpu
369 short-term CPU usage factor (for scheduling)
370 .It Cm f
371 the process flags, in hexadecimal (alias
372 .Cm flags )
373 .It Cm inblk
374 total blocks read (alias
375 .Cm inblock )
376 .It Cm jail
377 jail ID
378 .It Cm jobc
379 job control count
380 .It Cm ktrace
381 tracing flags
382 .It Cm ktracep
383 tracing vnode
384 .It Cm lastcpu
385 CPU ID the process was last scheduled on
386 .It Cm lim
387 memoryuse limit
388 .It Cm login
389 login name of user who started the process (alias
390 .Cm logname )
391 .It Cm lstart
392 time started
393 .It Cm majflt
394 total page faults
395 .It Cm minflt
396 total page reclaims
397 .It Cm msgrcv
398 total messages received (reads from pipes/sockets)
399 .It Cm msgsnd
400 total messages sent (writes on pipes/sockets)
401 .It Cm nice
402 nice value (alias
403 .Cm ni )
404 .It Cm nivcsw
405 total involuntary context switches
406 .It Cm nsigs
407 total signals taken (alias
408 .Cm nsignals )
409 .It Cm nswap
410 total swaps in/out
411 .It Cm nvcsw
412 total voluntary context switches
413 .It Cm nwchan
414 wait channel (as an address)
415 .It Cm oublk
416 total blocks written (alias
417 .Cm oublock )
418 .It Cm p_ru
419 resource usage (valid only for zombie)
420 .It Cm paddr
421 swap address
422 .It Cm pagein
423 pageins (same as
424 .Cm majflt )
425 .It Cm pgid
426 process group number
427 .It Cm pid
428 process ID
429 .It Cm ppid
430 parent process ID
431 .It Cm pri
432 scheduling priority (lower == better)
433 .It Cm re
434 core residency time (in seconds; 127 = infinity)
435 .It Cm rgid
436 real group ID
437 .It Cm rlink
438 reverse link on run queue, or 0
439 .It Cm rss
440 resident set size
441 .It Cm rsz
442 resident set size + (text size / text use count) (alias
443 .Cm rssize )
444 .It Cm rtprio
445 realtime priority (101 = not a realtime process)
446 .It Cm ruid
447 real user ID
448 .It Cm ruser
449 user name (from ruid)
450 .It Cm sess
451 session pointer
452 .It Cm sig
453 pending signals (alias
454 .Cm pending )
455 .It Cm sigcatch
456 caught signals (alias
457 .Cm caught )
458 .It Cm sigignore
459 ignored signals (alias
460 .Cm ignored )
461 .It Cm sigmask
462 blocked signals (alias
463 .Cm blocked )
464 .It Cm sl
465 sleep time (in seconds; 127 = infinity)
466 .It Cm start
467 time started
468 .It Cm state
469 symbolic process state (alias
470 .Cm stat )
471 .It Cm svgid
472 saved gid from a setgid executable
473 .It Cm svuid
474 saved uid from a setuid executable
475 .It Cm tdev
476 control terminal device number
477 .It Cm tdpri
478 LWKT thread priority (0-31, 31 highest), and critical section count
479 .It Cm time
480 accumulated CPU time, user + system (alias
481 .Cm cputime )
482 .It Cm tpgid
483 control terminal process group ID
484 .\".It Cm trss
485 .\"text resident set size (in Kbytes)
486 .It Cm tsess
487 control terminal session pointer
488 .It Cm tsiz
489 text size (in Kbytes)
490 .It Cm tt
491 control terminal name (two letter abbreviation)
492 .It Cm tty
493 full name of control terminal
494 .It Cm ucomm
495 name to be used for accounting
496 .It Cm uid
497 effective user ID
498 .It Cm user
499 user name (from uid)
500 .It Cm vsz
501 virtual size in Kbytes (alias
502 .Cm vsize )
503 .It Cm wchan
504 wait channel (as a symbolic name)
505 .It Cm xstat
506 exit or stop status (valid only for stopped or zombie process)
507 .El
508 .Sh FILES
509 .Bl -tag -width /var/db/kvm_kernel.db -compact
510 .It Pa /dev/kmem
511 default kernel memory
512 .It Pa /var/run/dev.db
513 /dev name database
514 .It Pa /var/db/kvm_kernel.db
515 system namelist database
516 .It Pa /kernel
517 default system namelist
518 .It Pa /proc
519 the mount point of
520 .Xr procfs 5
521 .El
522 .Sh SEE ALSO
523 .Xr kill 1 ,
524 .Xr w 1 ,
525 .Xr kvm 3 ,
526 .Xr strftime 3 ,
527 .Xr procfs 5 ,
528 .Xr pstat 8 ,
529 .Xr sysctl 8
530 .Sh HISTORY
531 The
532 .Nm
533 command appeared in
534 .At v4 .
535 .Sh BUGS
536 Since
537 .Nm
538 cannot run faster than the system and is run as any other scheduled
539 process, the information it displays can never be exact.