linuxÉó²éÀú³Ì״̬µÄÏÂÁî
linuxÖÐÉó²éÀú³Ì״̬µÄÏÂÁîÖ÷ÒªÓÐpsºÍtop£¬psÏÂÁî³£ÓÃÑ¡Ïî°üÀ¨-aÏÔʾËùÓÐÀú³Ì¡¢-eµÈͬÓÚ-a¡¢-auxÏÔʾÏêϸÐÅÏ¢¡¢-fÏÔʾȫÃûÌÃÐÅÏ¢¡¢-lÏÔʾ³¤ÃûÌÃÐÅÏ¢¡¢-pÉó²éÖ¸¶¨pid¡¢-uÉó²éÖ¸¶¨Óû§Àú³Ì£»topÏÂÁîÓÃÓÚʵʱÉó²éÀú³Ì״̬£¬³£ÓÃÑ¡ÏîÓÐ-bÅú´¦Öóͷ£Ä£Ê½¡¢-dÉèÖøüÐÂÑÓ³Ù¡¢-uÖ¸¶¨Óû§¡¢-pÖ¸¶¨pid¡£
Linux Éó²éÀú³Ì״̬µÄÏÂÁî
ps ÏÂÁîÊÇ Linux ϵͳÖÐÓÃÓÚÉó²éÀú³Ì״̬µÄ×î³£ÓÃÏÂÁîÖ®Ò»¡£Ëüͨ³£ÒÔÒÔÏÂÃûÌÃʹÓãº
ps [Ñ¡Ïî]
µÇ¼ºó¸´ÖÆ
³£ÓÃÑ¡Ï
-A: ÏÔʾËùÓÐÀú³Ì£¬°üÀ¨ËÀÀú³Ì¡£
-e: ÏÔʾËùÓÐÀú³Ì£¬µÈͬÓÚ -A¡£
-aux: ÏÔʾÏêϸµÄÀú³ÌÐÅÏ¢£¬°üÀ¨Óû§¡¢PID¡¢CPU ºÍÄÚ´æʹÓÃÂʵȡ£
-f: ÏÔʾȫÃûÌõÄÀú³ÌÐÅÏ¢£¬Ìṩ¸ü¶àÏêϸÐÅÏ¢¡£
-l: ÏÔʾ³¤ÃûÌõÄÀú³ÌÐÅÏ¢£¬°üÀ¨Ïß³ÌÐÅÏ¢¡£
-p PID: ÏÔʾָ¶¨ PID µÄÀú³ÌÐÅÏ¢¡£
-U USER: ÏÔʾָ¶¨Óû§Æô¶¯µÄÀú³Ì¡£
ʾÀý£º
Éó²éËùÓÐÕýÔÚÔËÐеÄÀú³Ì£ºps -A
Éó²éÖ¸¶¨Óû§µÄÀú³Ì£ºps -U username
Éó²éÖ¸¶¨ PID µÄÀú³Ì£ºps -p 1234
top ÏÂÁîÊÇÁíÒ»¸öÉó²éÀú³Ì״̬µÄÊÊÓù¤¾ß¡£ËüÌṩÁËʵʱ¸üеÄÀú³ÌÐÅÏ¢£¬°üÀ¨ CPU ºÍÄÚ´æʹÓÃÂÊ¡£
top [Ñ¡Ïî]
µÇ¼ºó¸´ÖÆ
³£ÓÃÑ¡Ï
-b: ÒÔÅú´¦Öóͷ£Ä£Ê½ÔËÐС£
-d: ÉèÖøüÐÂÑÓ³Ùʱ¼ä£¨ÒÔÃëΪµ¥Î»£©¡£
-u: Ö¸¶¨Òª¼àÊÓµÄÓû§¡£
-p: Ö¸¶¨Òª¼àÊ PID¡£
ʾÀý£º
ÒÔ½»»¥Ä£Ê½Æô¶¯ top£ºtop
ÒÔÅú´¦Öóͷ£Ä£Ê½ÔËÐÐ top ²¢Êä³öЧ¹ûµ½Îļþ£ºtop -b > output.txt
ÆäËûÏÂÁ
³ýÁË ps ºÍ top ÏÂÁîÍ⣬ÉÐÓÐÆäËûÏÂÁî¿ÉÒÔÓÃÀ´Éó²éÀú³Ì״̬£¬ÀýÈ磺
pstree: ÒÔÊ÷×´½á¹¹ÏÔʾÀú³Ì¡£
pidstat: ÌṩÓйØÀú³Ì×ÊÔ´ÏûºÄµÄÏêϸͳ¼ÆÐÅÏ¢¡£
iostat: ÏÔʾ´ÅÅÌ I/O ͳ¼ÆÐÅÏ¢¡£
ÒÔÉϾÍÊÇlinuxÉó²éÀú³Ì״̬µÄÏÂÁîµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡