À´Ô´¡¶Äñ¸çµÄlinux˽·¿²Ë¡·
ps£º½«Ä³¸öʱ¼äµãµÄ³ÌÐòÔË×÷Çé¿öߢȡÏÂÀ´
[root @linux ~] # ps aux [root @linux ~] # ps -lA [root @linux ~] # ps axjf ²ÎÊý£º - A £ºËùÓÐµÄ process ¾ùÏÔʾ³öÀ´£¬Óë -e ¾ßÓÐͬÑùµÄЧÓã» -a £º²»Óë terminal ÓйصÄËùÓÐ process £» -u £ºÓÐЧʹÓÃÕß (effective user) Ïà¹ØµÄ process £» x £ºÍ¨³£Óë a Õâ¸ö²ÎÊýÒ»ÆðʹÓ㬿ÉÁгö½ÏÍêÕûÐÅÏ¢¡£ Êä³ö¸ñʽ¹æ»®£º l £º½Ï³¤¡¢½ÏÏêϸµÄ½«¸Ã PID µÄµÄÐÅÏ¢Áгö£» j £º¹¤×÷µÄ¸ñʽ (jobs format) -f £º×öÒ»¸ö¸üΪÍêÕûµÄÊä³ö¡£ Ìرð˵Ã÷£º ÓÉÓÚ ps Äܹ»Ö§³ÖµÄ OS ÀàÐÍÏ൱µÄ¶à£¬ËùÒÔËûµÄ²ÎÊý¶àµÄÀëÆ×£¡ ¶øÇÒÓÐûÓмÓÉÏ - ²îºÜ¶à£¡ÏêϸµÄÓ÷¨Ó¦¸ÃÒª²Î¿¼ man ps ร¡ |
·¶Àý1£º½«Ä¿Ç°ÊôÓÚÄú×Ô¼ºÕâ´ÎµÇÈëµÄ PID ÓëÏà¹ØÐÅÏ¢ÁÐʾ³öÀ´
[root @linux ~] # ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S 0 5881 5654 0 76 0 - 1303 wait pts/ 0 00 : 00 : 00 su 4 S 0 5882 5881 0 75 0 - 1349 wait pts/ 0 00 : 00 : 00 bash 4 R 0 6037 5882 0 76 0 - 1111 - pts/ 0 00 : 00 : 00 ps |
# ÉÏÃæÕâ¸öÐÅÏ¢ÆäʵºÜ¶àร¡¸÷Ïà¹ØÐÅÏ¢µÄÒâÒåΪ£º # F ´ú±íÕâ¸ö³ÌÐòµÄÆì±ê (flag)£¬ 4 ´ú±íʹÓÃÕßΪ super user£» # S ´ú±íÕâ¸ö³ÌÐòµÄ״̬ (STAT)£¬¹ØÓÚ¸÷ STAT µÄÒâÒ彫ÔÚÄÚÎĽéÉÜ£» # PID ûÎÊÌâ°É£¡£¿¾ÍÊÇÕâ¸ö³ÌÐòµÄ ID °¡£¡µ×Ï嵀 PPID ÔòÉϸ¸³ÌÐòµÄ ID£» # C CPU ʹÓõÄ×ÊÔ´°Ù·Ö±È # PRI Õâ¸öÊÇ Priority (ÓÅÏÈÖ´ÐÐÐò) µÄËõд£¬ÏêϸºóÃæ½éÉÜ£» # NI Õâ¸öÊÇ Nice Öµ£¬ÔÚÏÂһС½ÚÎÒÃÇ»á³ÖÐø½éÉÜ¡£ # ADDR Õâ¸öÊÇ kernel function£¬Ö¸³ö¸Ã³ÌÐòÔÚÄÚ´æµÄÄǸö²¿·Ö¡£Èç¹ûÊǸö running # µÄ³ÌÐò£¬Ò»°ã¾ÍÊÇ¡º - ¡»µÄÀ²£¡ # SZ ʹÓõôµÄÄÚ´æ´óС£» # WCHAN Ä¿Ç°Õâ¸ö³ÌÐòÊÇ·ñÕýÔÚÔË×÷µ±ÖУ¬ÈôΪ - ±íʾÕýÔÚÔË×÷£» # TTY µÇÈëÕßµÄÖն˻úλÖƪ£» # TIME ʹÓõôµÄ CPU ʱ¼ä¡£ # CMD ËùÏ´ïµÄÖ¸ÁîΪºÎ£¡£¿ # ×Ðϸ¿´µ½Ã¿Ò»¸ö³ÌÐòµÄ PID Óë PPID µÄÏà¹ØÐÔΪºÎร¡ÉÏÍ·ÁгöµÄÈý¸ö³ÌÐòÖУ¬ # ±Ë´Ë¼ä¿ÉÊÇÓÐÏà¹ØÐԵąȣ¡ |
·¶Àý2£ºÁгöÄ¿Ç°ËùÓеÄÕýÔÚÄÚ´æµ±ÖеijÌÐò
[root @linux ~] # ps aux USER PID % CPU % MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0 . 0 0 . 1 1740 540 ? S Jul25 0 : 01 init [ 3 ] root 2 0 . 0 0 . 0 0 0 ? SN Jul25 0 : 00 [ksoftirqd/ 0 ] root 3 0 . 0 0 . 0 0 0 ? S < Jul25 0 : 00 [events/ 0 ] .....ÖмäÊ¡ÂÔ..... root 5881 0 . 0 0 . 3 5212 1204 pts/ 0 S 10 : 22 0 : 00 su root 5882 0 . 0 0 . 3 5396 1524 pts/ 0 S 10 : 22 0 : 00 bash root 6142 0 . 0 0 . 2 4488 916 pts/ 0 R + 11 : 45 0 : 00 ps aux |
• USER £º¸Ã process ÊôÓÚÄǸöʹÓÃÕßÕ˺ŵģ¿ • PID £º¸Ã process µÄºÅÂë¡£ • % CPU £º¸Ã process ʹÓõôµÄ CPU ×ÊÔ´°Ù·Ö±È£» • % MEM £º¸Ã process ËùÕ¼ÓõÄÎïÀíÄÚ´æ°Ù·Ö±È£» • VSZ £º¸Ã process ʹÓõôµÄÐéÄâÄÚ´æÁ¿ (Kbytes) • RSS £º¸Ã process Õ¼ÓõĹ̶¨µÄÄÚ´æÁ¿ (Kbytes) • TTY £º¸Ã process ÊÇÔÚÄǸöÖն˻úÉÏÃæÔË×÷£¬ÈôÓëÖն˻úÎ޹أ¬ÔòÏÔʾ ?£¬ÁíÍ⣬ tty1-tty6 ÊDZ¾»úÉÏÃæµÄµÇÈëÕß³ÌÐò£¬ÈôΪ pts/ 0 µÈµÈµÄ£¬Ôò±íʾΪÓÉÍøÂçÁ¬½Ó½øÖ÷»úµÄ³ÌÐò¡£ • STAT £º¸Ã³ÌÐòÄ¿Ç°µÄ״̬£¬Ö÷ÒªµÄ״̬ÓУº o R £º¸Ã³ÌÐòÄ¿Ç°ÕýÔÚÔË×÷£¬»òÕßÊǿɱ»ÔË×÷£» o S £º¸Ã³ÌÐòÄ¿Ç°ÕýÔÚ˯Ãßµ±ÖÐ (¿É˵ÊÇ idle ״̬À²£¡)£¬µ«¿É±»Ä³Ð©Ñ¶ºÅ (signal) »½ÐÑ¡£ o T £º¸Ã³ÌÐòÄ¿Ç°ÕýÔÚÕì²â»òÕßÊÇÍ£Ö¹ÁË£» o Z £º¸Ã³ÌÐòÓ¦¸ÃÒѾÖÕÖ¹£¬µ«ÊÇÆ丸³ÌÐòÈ´ÎÞ·¨Õý³£µÄÖÕÖ¹Ëû£¬Ôì³É zombie (½®Ê¬) ³ÌÐòµÄ״̬ • START £º¸Ã process ±»´¥·¢Æô¶¯µÄʱ¼ä£» • TIME £º¸Ã process ʵ¼ÊʹÓà CPU ÔË×÷µÄʱ¼ä¡£ • COMMAND £º¸Ã³ÌÐòµÄʵ¼ÊÖ¸ÁîΪºÎ£¿ |
·¶Àý3£ºÒÔ·¶ÀýÒ»µÄÏÔʾÄÚÈÝ£¬ÏÔʾ³öËùÓеijÌÐò
[root @linux ~] # ps -lA F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 4 S 0 1 0 0 76 0 - 435 - ? 00 : 00 : 01 init 1 S 0 2 1 0 94 19 - 0 ksofti ? 00 : 00 : 00 ksoftirqd/ 0 1 S 0 3 1 0 70 - 5 - 0 worker ? 00 : 00 : 00 events/ 0 .....ÒÔÏÂÊ¡ÂÔ..... |
·¶Àý4£ºÁгöÀàËƳÌÐòÊ÷µÄ³ÌÐòÏÔʾ
[root @linux ~] # ps -axjf PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND 0 1 0 0 ? - 1 S 0 0 : 01 init [ 3 ] 1 2 0 0 ? - 1 SN 0 0 : 00 [ksoftirqd/ 0 ] .....ÖмäÊ¡ÂÔ..... 1 5281 5281 5281 ? - 1 Ss 0 0 : 00 /usr/sbin/sshd 5281 5651 5651 5651 ? - 1 Ss 0 0 : 00 \ _ sshd: dmtsai [priv] 5651 5653 5651 5651 ? - 1 S 500 0 : 00 \ _ sshd: dmtsai @pts / 0 5653 5654 5654 5654 pts/ 0 6151 Ss 500 0 : 00 \ _ -bash 5654 5881 5881 5654 pts/ 0 6151 S 0 0 : 00 \ _ su 5881 5882 5882 5654 pts/ 0 6151 S 0 0 : 00 \ _ bash 5882 6151 6151 5654 pts/ 0 6151 R + 0 0 : 00 \ _ ps -axjf |
·¶Àý5£ºÕÒ³öÓë cron Óë syslog ÕâÁ½¸ö·þÎñÓÐ¹ØµÄ PID ºÅÂë
[root @linux ~] # ps aux | egrep '(cron|syslog)' root 1539 0 . 0 0 . 1 1616 616 ? Ss Jul25 0 : 03 syslogd -m 0 root 1676 0 . 0 0 . 2 4544 1128 ? Ss Jul25 0 : 00 crond root 6157 0 . 0 0 . 1 3764 664 pts/ 0 R + 12 : 10 0 : 00 egrep (cron|syslog) |
ÔÚÔ¤ÉèµÄÇé¿öÏ£¬ ps ½ö»áÁгöÓëÄ¿Ç°ËùÔÚµÄ bash shell ÓÐ¹ØµÄ PID ¶øÒÑ£¬ËùÒÔ£¬ µ±ÎÒʹÓà ps -l µÄʱºò£¬Ö»ÓÐÈý¸ö PID (·¶ÀýÒ»)¡£
ÍƼöÐÅÏ¢
- linuxÃüÁîѧϰ±Ê¼Ç£¨11£©£ºnlÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨5£©£ºrmÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨4£©£ºmkdirÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨1£©£ºlsÃüÁî
- ½«CentosµÄyumÔ´¸ü»»Îª¹úÄڵİ¢ÀïÔÆÔ´
- ʹÓÃNginxÌí¼Óheader·ÀÖ¹ÍøÒ³±»frame
- linuxϼÓËÙscp´«Êä´óÎļþµÄËÙ¶È
- linuxϵͳÉ϶ÔnginxÈÕÖ¾·Ö¸î´¦Àí
- lnmp/nginxϵͳÕæÕýÓÐЧµÄͼƬ·ÀµÁÁ´ÍêÕûÉèÖÃÏê½â
- Í»ÆÆÊ®Íò²¢·¢µÄNginxµÄÅäÖü°ÓÅ»¯
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- ²éÕÒ²¢É¾³ý.svnĿ¼Îļþ
- redis ÆßÖÖÊý¾ÝÀàÐ͵ÄʹÓó¡¾°
- linux ÏÂÎļþ¸´ÖƵ½windowsÏÂÂÒÂëµÄ½â¾ö°ì·¨
- nginx³öÏÖ502 upstream sent too big he....
- linuxÏÂsudoÅäÖÃÏê½â
- linuxÃüÁîѧϰ±Ê¼Ç£¨15£©£ºtailÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨14£©£ºheadÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨13£©£ºlessÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨12£©£ºmoreÃüÁî
- ¼ÓÃÜËã·¨±È½Ï3DES AES RSA ECC MD5 SHA1µÈ
ÆÀÂÛ