⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ps.1

📁 Linux下进程监控相关源代码
💻 1
字号:
,\" t.\" (The preceding line is a note to broken versions of man to tell.\" them to pre-process this man page with tbl).\" Man page for ps..\" Licensed under version 2 of the GNU General Public License..\" Modified by Michael K. Johnson from a gross plain-text hack.\" by Albert Cahalan of Michael's original version..\".TH PS 1 "March 11, 1999" "Linux" "Linux User's Manual".SH NAMEps \- report process status.SH SYNOPSISps [\fIoptions\fP].SH DESCRIPTIONps gives a snapshot of the current processes. If you wanta repetitive update of this status, use top. This manpage documents the /proc-based version of ps, or tries to..SH "COMMAND-LINE OPTIONS"This version of ps accepts several kinds of options..br.RSUnix98 options may be grouped and must be preceeded by a dash..brBSD options may be grouped and must not be used with a dash..brGNU long options are preceeded by two dashes..RE.brOptions of different types may be freely mixed.Set the \f(CWI_WANT_A_BROKEN_PS\fR environment variable to force BSDsyntax even when options are preceeded by a dash. The \f(CWPS_PERSONALITY\fRenvironment variable (described below) provides more detailed control ofps behavior..SS "SIMPLE PROCESS SELECTION".TSlB lBlfCW l.Switch	Description.TH-A	select all processes-N	negate selection-a	select all with a tty except session leaders-d	select all, but omit session leaders-e	select all processesT	select all processes on this terminala	T{select all processes on a terminal, including those of other usersT}g	T{really all, even group leaders (does nothing w/o SunOS settings)T}r	restrict output to running processesx	select processes without controlling ttys--deselect	negate selection.TE.SS "PROCESS SELECTION BY LIST".TSlB lBlfCW l.Switch	Description.TH-C	select by command name-G	select by RGID (supports names)-U	select by RUID (supports names)-g	select by session leader OR by group name-p	select by PID-s	select processes belonging to the sessions given-t	select by tty-u	select by effective user ID (supports names)U	select processes for specified usersp	select by process IDt	select by tty--Group	select by real group name or ID--User	select by real user name or ID--group	select by effective group name or ID--pid	select by process ID--sid	select by session ID--tty	select by terminal--user	select by effective user name or ID-123	implied --sid123	implied --pid.TE.SS "OUTPUT FORMAT CONTROL".TSlB lBlfCW l.Switch	Description.TH-O	is preloaded "-o"-c	different scheduler info for -l option-f	does full listing-j	jobs format-l	long format-o	user-defined format-y	do not show flags; show rss in place of addrO	is preloaded "o" (overloaded)X	old Linux i386 register formatj	job control formatl	display long formato	specify user-defined formats	display signal formatu	display user-oriented formatv	display virtual memory format--format	user-defined format.TE.SS "OUTPUT MODIFIERS".TSlB lBlfCW l.Switch	Description.TH-H	show process hierarchy (forest)-m	show threads-n	set namelist file-w	wide outputC	use raw CPU time for %CPU instead of decaying averageN	specify namelist fileO	sorting order (overloaded)S	T{include some dead child process data (as a sum with the parent)T}c	true command namee	show environment after the commandf	ASCII-art process hierarchy (forest)h	T{do not print header lines (repeat header lines in BSD personality)T}m	all threadsn	numeric output for WCHAN and USERw	wide output--cols	set screen width--columns	set screen width--cumulative	T{include some dead child process data (as a sum with the parent)T}--forest	ASCII art process tree--html	HTML escaped output--headers	repeat header lines--no-headers	print no header line at all--lines	set screen height--nul	unjustified output with NULs--null	unjustified output with NULs--rows	set screen height--sort	specify sorting order--width	set screen width--zero	unjustified output with NULs.TE.SS INFORMATION.TSlB lBlfCW l.Switch	Description.TH-V	print versionL	list all format specifiersV	show version info--help	print help message--info	print debugging info--version	print version.TE.SS OBSOLETE.TSlB lBlfCW l.Switch	Description.THA	increase the argument space (DecUnix)M	use alternate core (try -n or N instead)W	get swap info from ... not /dev/drum (try -n or N instead)k	use /vmcore as c-dumpfile (try -n or N instead).TE.SH NOTESThe "-g" option can select by session leader OR by group name.Selection by session leader is specified by many standards,but selection by group is the logical behavior that several otheroperating systems use. This ps will select by session leader whenthe list is completely numeric (as sessions are). Group ID numberswill work only when some group names are also specified.The "m" option should not be used. Use "-m" or "-o" with a list.("m" displays memory info, shows threads, or sorts by memory use)The "h" option is problematic.  Standard BSD ps uses the option toprint a header on each page of output, but older Linux ps uses the optionto totally disable the header.  This version of ps follows the Linuxusage of not printing the header unless the BSD personality has beenselected, in which case it prints a header on each page of output.Regardless of the current personality, you can use the long options--headers and --no-headers to enable printing headers each page anddisable headers entirely, respectively.Terminals (ttys, or screens of text output) can be specified in severalforms: /dev/ttyS1, ttyS1, S1. Obsolete "ps t" (your own terminal) and"ps t?" (processes without a terminal) syntax is supported, but modernoptions ("T", "-t" with list, "x", "t" with list) should be used instead.The BSD "O" option can act like "-O" (user-defined output format withsome common fields predefined) or can be used to specify sort order.Heuristics are used to determine the behavior of this option. To ensurethat the desired behavior is obtained, specify the other option (sortingor formatting) in some other way.For sorting, BSD "O" option syntax is O[+|-]k1[,[+|-]k2[,...]]Order the process listing according to the multilevel sort specified bythe sequence of short keys from SORT KEYS, k1, k2, ... The `+' is quiteoptional, merely re-iterating the default direction on a key. `-' reversesdirection only on the key it precedes. The O option must be the last optionin a single command argument, but specifications in successive arguments arecatenated.GNU sorting syntax is --sortX[+|-]key[,[+|-]key[,...]]Choose a multi-letter key from the SORT KEYS section. X may be anyconvenient separator character. To be GNU-ish use `='. The `+' is reallyoptional since default direction is increasing numerical or lexicographicorder. For example, ps jax --sort=uid,-ppid,+pidThis ps works by reading the virtual files in /proc. This ps does notneed to be suid kmem or have any privileges to run. Do not give this psany special permissions.This ps needs access to a namelist file for proper WCHAN display.The namelist file must match the current Linux kernel exactly forcorrect output.To produce the WCHAN field, ps needs to read the System.map file createdwhen the kernel is compiled. The search path is:.RS$PS_SYSTEM_MAP.br/boot/System.map-`uname -r`.br/boot/System.map.br/lib/modules/`uname -r`/System.map.br/usr/src/linux/System.map.br/System.map.REThe member used_math of task_struct is not shown, since crt0.s checksto see if math is present. This causes the math flag to be set for allprocesses, and so it is worthless. (Somebody fix libc or the kernel please.)Programs swapped out to disk will be shown without command line arguments,and unless the c option is given, in brackets.%CPU shows the cputime/realtime percentage. It will not add up to 100%unless you are lucky. It is time used divided by the time the process hasbeen running.The SIZE and RSS fields don't count the page tables and the task_struct of aproc; this is at least 12k of memory that is always resident. SIZE is thevirtual size of the proc (code+data+stack).Processes marked <defunct> are dead processes (so-called "zombies")that remain because their parent has not destroyed them properly. Theseprocesses will be destroyed by init(8) if the parent process exits..SS "PROCESS FLAGS".TSlfCW lfCW l.ALIGNWARN	001	print alignment warning msgsSTARTING	002	being createdEXITING	004	getting shut downPTRACED	010	set if ptrace (0) has been calledTRACESYS	020	tracing system callsFORKNOEXEC	040	forked but didn't execSUPERPRIV	100	used super-user privilegesDUMPCORE	200	dumped coreSIGNALED	400	killed by a signal.TE.SS "PROCESS STATE CODES".TSlfCW l.D	uninterruptible sleep (usually IO)R	runnable (on run queue)S	sleepingT	traced or stoppedZ	a defunct ("zombie") process.TEFor BSD formats and when the "stat" keyword is used, additionalletters may be displayed:.TSlfCW l.W	has no resident pages<	high-priority processN	low-priority taskL	has pages locked into memory (for real-time and custom IO).TE.SS "SORT KEYS"Note that the values used in sorting are the internal values ps uses and notthe `cooked' values used in some of the output format fields. Pipe psoutput into the sort(1) command if you want to sort the cooked values..TSlB lB lBlfCW lfCW l.KEY	LONG	DESCRIPTION.THc	cmd	simple name of executableC	cmdline	full command linef	flags	flags as in long format F fieldg	pgrp	process group IDG	tpgid	controlling tty process group IDj	cutime	cumulative user timeJ	cstime	cumulative system timek	utime	user timeK	stime	system timem	min_flt	number of minor page faultsM	maj_flt	number of major page faultsn	cmin_flt	cumulative minor page faultsN	cmaj_flt	cumulative major page faultso	session	session IDp	pid	process IDP	ppid	parent process IDr	rss	resident set sizeR	resident	resident pagess	size	memory size in kilobytesS	share	amount of shared pagest	tty	the minor device number of ttyT	start_time	time process was startedU	uid	user ID numberu	user	user namev	vsize	total VM size in bytesy	priority	kernel scheduling priority.TE.SS "AIX FORMAT DESCRIPTORS"This ps supports AIX format descriptors, which work somewhat like theformatting codes of printf(1) and printf(3). For example, the normaldefault output can be produced with this:   ps -eo "%p %y %x %c".TSlB lB lBlfCW lfCW l.CODE	NORMAL	HEADER.TH%C	pcpu	%CPU%G	group	GROUP%P	ppid	PPID%U	user	USER%a	args	COMMAND%c	comm	COMMAND%g	rgroup	RGROUP%n	nice	NI%p	pid	PID%r	pgid	PGID%t	etime	ELAPSED%u	ruser	RUSER%x	time	TIME%y	tty	TTY%z	vsz	VSZ.TE.SS "STANDARD FORMAT SPECIFIERS"These may be used to control both output format and sorting..brFor example:  ps -eo pid,user,args --sort user.TSlB lBlfCW lfCW.CODE	HEADER.TH%cpu	%CPU%mem	%MEMalarm	ALARMargs	COMMANDblocked	BLOCKEDbsdstart	STARTbsdtime	TIMEc	Ccaught	CAUGHTcmd	CMDcomm	COMMANDcommand	COMMANDcputime	TIMEdrs	DRSdsiz	DSIZegid	EGIDegroup	EGROUPeip	EIPesp	ESPetime	ELAPSEDeuid	EUIDeuser	EUSERf	Ffgid	FGIDfgroup	FGROUPflag	Fflags	Ffname	COMMANDfsgid	FSGIDfsgroup	FSGROUPfsuid	FSUIDfsuser	FSUSERfuid	FUIDfuser	FUSERgid	GIDgroup	GROUPignored	IGNOREDintpri	PRIlim	LIMlongtname	TTYlstart	STARTEDm_drs	DRSm_trs	TRSmaj_flt	MAJFLmajflt	MAJFLTmin_flt	MINFLminflt	MINFLTni	NInice	NInwchan	WCHANopri	PRIpagein	PAGEINpcpu	%CPUpending	PENDINGpgid	PGIDpgrp	PGRPpid	PIDpmem	%MEMppid	PPIDpri	PRIrgid	RGIDrgroup	RGROUPrss	RSSrssize	RSSrsz	RSZruid	RUIDruser	RUSERs	Ssess	SESSsession	SESSsgi_p	Psgi_rss	RSSsgid	SGIDsgroup	SGROUPsid	SIDsig	PENDINGsig_block	BLOCKEDsig_catch	CATCHEDsig_ignore	IGNOREDsig_pend	SIGNALsigcatch	CAUGHTsigignore	IGNOREDsigmask	BLOCKEDstackp	STACKPstart	STARTEDstart_stack	STACKPstart_time	STARTstat	STATstate	Sstime	STIMEsuid	SUIDsuser	SUSERsvgid	SVGIDsvgroup	SVGROUPsvuid	SVUIDsvuser	SVUSERsz	SZtime	TIMEtimeout	TMOUTtmout	TMOUTtname	TTYtpgid	TPGIDtrs	TRStrss	TRSStsiz	TSIZtt	TTtty	TTtty4	TTYtty8	TTYucomm	COMMANDuid	UID	uid_hack	UIDuname	USER	user	USER	vsize	VSZ	vsz	VSZ	wchan	WCHAN	.TE.SS "ENVIRONMENT VARIABLES"The following environment variables could affect ps:.TSlfCW l.COLUMNS	Override default display widthLINES	Override default display heightPS_PERSONALITY	Set to one of posix,old,linux,bsd,sun,digitalCMD_ENV	Set to one of posix,old,linux,bsd,sun,digitalI_WANT_A_BROKEN_PS	Force obsolete command line interpretationLC_TIME	Date formatPS_FORMAT	Default output format overridePS_SYSMAP	Default namelist (System.map) locationPS_SYSTEM_MAP	Default namelist (System.map) locationPOSIXLY_CORRECT	Don't find excuses to ignore bad "features"UNIX95	Don't find excuses to ignore bad "features"_XPG	Cancel CMD_ENV=irix non-standard behavior.TEIn general, it is a bad idea to set these variables. The two exceptionsare CMD_ENV (or PS_PERSONALITY), to set the desired default personality,and POSIXLY_CORRECT (or UNIX95), which should be set for Unix98 standardcompliance..TSlfCW lblfCW l.PS_PERSONALITY	Description.TH\fInone\fP	"Do the right thing"aix	like AIX psbsd	like FreeBSD pscompaq	like Digital Unix psdebian	like the old Debian psdigital	like Digital Unix psgnu	like the old Debian pshp	like HP-UX pshpux	like HP-UX psirix	like Irix pslinux	deviate from Unix98 for convenience onlyold	like the original Linux psposix	standardsco	like SCO pssgi	like Irix pssun	like SunOS 4 pssunos	like SunOS 4 pssysv	standardunix	standardunix95	standardunix98	standard.TE.SH EXAMPLESTo see every process on the system using standard syntax:.RSps -e.RETo see every process on the system using BSD syntax:.RSps ax.RETo see every process except those running as root (real & effective ID).RSps -U root -u root -N.RETo see every process with a user-defined format:.RSps -eo pid,tt,user,fname,tmout,f,wchan.REOdd display with AIX field descriptors:.RSps -o "%u : %U : %p : %a".REPrint only the process IDs of syslogd:.RSps -C syslogd -o pid=.RE.SH "SEE ALSO"top(1) pstree(1) proc(5).SH STANDARDSThis ps can be set to conform to version 2 of the Single Unix Specification..SH AUTHORps was originally written by Branko Lankester <lankeste@fwi.uva.nl>..brMichael K. Johnson <johnsonm@redhat.com> re-wrote it significantly touse the proc filesystem, changing a few things in the process..brMichael Shields <shields@msrl.com> added the pid-list feature..brCharles Blake <cblake@bbn.com> added multi-level sorting, the dirent-stylelibrary, the device name-to-number mmaped database, the approximatebinary search directly on System.map, and many code and documentation cleanups..brDavid Mosberger-Tang wrote the generic BFD support for psupdate..brAlbert Cahalan <acahalan@cs.uml.edu> rewrote ps for full Unix98 andBSD support, along with some ugly hacks for obsolete and foreign syntax.Michael K. Johnson <johnsonm@redhat.com> is the current maintainer.Please send bug reports to <procps-bugs@redhat.com>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -