ºìÁªLinuxÃÅ»§
Linux°ïÖú

Solaris½ø³ÌµÄ²é¿´ºÍ¹ÜÀí

·¢²¼Ê±¼ä:2006-08-13 21:57:08À´Ô´:ºìÁª×÷Õß:M-zone
1¡¢Ê²Ã´Êǽø³Ì£¿
¡¡¡¡½ø³Ì£º¿É²¢·¢Ö´ÐеijÌÐòÔÚÒ»¶¨Êý¾Ý¼¯ºÏÉϵÄÔËÐйý³Ì¡£½ø³Ì¼´ÊÇ×ÊÔ´·ÖÅäµÄ»ù±¾µ¥Î»£¬Ò²Êǵ÷¶ÈºÍ·ÖÅɵĻù±¾µ¥Î»¡£
2¡¢UNIX²Ù×÷ϵͳ½ø³Ìµ÷¶ÈËã·¨£º
¡¡¡¡¶à¼¶·´À¡µ÷¶È¶ÓÁÐËã·¨¡£
3¡¢½ø³Ì״̬£º´´½¨¡¢³õʼ¡¢¾ÍÐ÷£¨»î¶¯¡¢¾²Ö¹£©¡¢Ö´ÐС¢×èÈû£¨»î¶¯¡¢¾²Ö¹£©¡¢½áÊø¡£
4¡¢½ø³Ì¼à¿ØÃüÁ
ps ÃüÁîºÍ½ø³Ì¹¤¾ß/usr/proc/binÏµĹ¤¾ß¼¶¡£
¿ÉÒÔ½«psºÍgrepÃüÁî×éºÏʹÓÃÀ´ËÑË÷Ìض¨µÄÐÅÏ¢¡£
5¡¢/usr/proc/binµÄÃüÁî½éÉÜ£º
pstop Í£Ö¹½ø³Ì
prun pid ÖØÐÂÆô¶¯½ø³Ì
ptime pid ʹÓÃ΢״̬¼ÆËã½ø³Ìʱ¼ä
pwait pid µÈ´ýÖ¸¶¨µÄ½ø³ÌÖÕÖ¹.
pcred pid ÏÔʾ¿ÉÐŶÈ
pfiles pid ÏÔʾÒÑ´ò¿ªÎļþµÄfstat ºÍfcntl ÐÅÏ¢
pflags pid ÏÔʾÿ¸ölwp µÄ/proc ¸ú×Ù±êÖ¾,µÈ´ýºÍ³ÖÓÐÐźÅÁ¿ÒÔ¼°ÆäËû×´
̬ÐÅÏ¢
pldd pid ÏÔʾÁ´½Óµ½Ã¿¸ö½ø³ÌµÄ¶¯Ì¬Á´½Ó¿â
pmap pid ÏÔʾµØÖ·Ó³Éä¿Õ¼ä
psig pid ÏÔʾÐźŲÙ×÷
pstack pid ÏÔʾÿ¸ölwp µÄÊ®Áù½øÖÆÓë·ûºÅ¶Ñ¸ú×Ù
ptree pid ÏÔʾ°üº¬Ö¸¶¨PID µÄ½ø³ÌÊ÷
pwdx oid ÏÔʾµ±Ç°¹¤×÷Ŀ¼
6¡¢psÃüÁî¸ñʽ£º
ps [ -aAdeflcjLPy ] [ -o format ] [ -t termlist ] [ -u userlist ] [ -U userlist ] [ -G grouplist ] [ -p proclist ] [ -g pgrplist ] [ -s sidlist ]
7¡¢³£ÓõIJÎÊý£º

-e Êä³öËùÓнø³Ì±¨¸æ
-f ÔÚµÚÒ»À¸ÏÔʾ½ø³ÌËùÓÐÕßµÄÃû×Ö(²»ÊÇUID)¡£¸ÃÑ¡Ïî¹Ø±Õ-l¡¢-t¡¢-s ºÍ-r Ñ¡Ïî,´ò¿ª-a Ñ¡Ïî¡£
-l ²úÉúÒ»¸ö³¤µÄÊä³ö±¨¸æ,Ö»ÊDz»°üº¬STIME ×Ö¶Î
8¡¢ps -elµÄÏà¹ØÊä³ö²ÎÊý½âÊÍ£º
bash-2.05$ ps -el
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
19 T 0 0 0 0 0 SY ? 0 ? 0:16 sched
8 S 0 1 0 0 40 20 ? 151 ? ? 0:00 init
19 S 0 2 0 0 0 SY ? 0 ? ? 0:00 pageout
19 S 0 3 0 0 0 SY ? 0 ? ? 0:30 fsflush
8 S 0 377 1 0 40 20 ? 223 ? ? 0:00 sac
8 S 0 378 1 0 40 20 ? 224 ? console 0:00 ttymon
8 S 0 131 1 0 40 20 ? 289 ? ? 0:00 rpcbind
F Ê®Áù½øÖƱêÖ¾£¬ËüÃǼÓÆðÀ´±íʾ½ø³ÌµÄµ±Ç°×´Ì¬¡£ÈçÏÂËùÊö£º
00 ½ø³ÌÖÕÖ¹£¬¶øÇÒËüÃÇÔÚ½ø³Ì±íÖеĿռäÒÑÊÍ·Å¡£
01 ϵͳ½ø³Ì£¬³¤×¤ÄÚ´æ
02 ½ø³Ì±»¸¸½ø³Ì¸ú×Ù
04 ½ø³Ì±»¸¸½ø³Ì¸ú×Ù¶øÇÒÒѱ»Í£Ö¹
08 ¸Ã½ø³ÌÎÞ·¨±»ÐźÅÁ¿»½ÐÑ
10 ¸Ã½ø³Ìµ±Ç°ÔÚÄÚ´æÖУ¬¶øÇÒ±»Ëø¶¨Ö±µ½Ò»¸öʼþÍê³É
20 ½ø³Ì²»Äܱ»½»»»³ö
S ½ø³Ìµ±Ç°×´Ì¬£¬ÓÉÒÔÏÂ×Öĸ֮һÏÔʾ£º
O µ±Ç°ÕýÔÚ´¦ÀíÆ÷ÉÏÔËÐÐ
S ˯Ãߣ»µÈ´ýI/OʼþÍê³É
R ÔËÐнáÊø
I ¿ÕÏУ»½ø³Ì±»´´½¨
Z ½©ËÀ¡£½ø³ÌÒÑÖÕÖ¹
T ÓÉÓÚ¸¸½ø³Ì¸ú×Ù¶øÍ£Ö¹
X µÈ´ý¸ü¶àµÄÄÚ´æ
UID ½ø³ÌËùÓÐÕßµÄÓû§ID
PID ½ø³ÌID
PPID ¸¸½ø³ÌID
C ½ø³ÌµÄCPUʹÓÃÇé¿ö£¨¼´½ø³ÌÕ¼CPUʱ¼äµÄ°Ù·Ö±È£©
PRI ½ø³ÌÓÅÏÈȨ·½°¸¡£½Ï´óµÄÊý±íʾ½ÏµÍµÄÓÅÏÈȨ
NI ½ø³ÌµÄniceÖµ£¬¸ÃÖµÓëÓÅÏÈȨ·½°¸Ïà¹ØÁª¡£Ê¹Ò»¸ö½ø³Ì¡°nicer¡±ÒâÖ¸½µµÍ¸Ã½ø³ÌµÄÓÅÏÈȨ£¬ÒÔʹËü²»»áÓþ¡CPUµÄʱ¼ä
SZ ½ø³ÌÇëÇóµÄÐéÄâÄÚ´æÁ¿¡£ÕâÊǸÃϵͳ¶ÔÄÚ´æÐèÇóµÄÒ»¸öºÃµÄÖ¸±ê¡£
TTY Æô¶¯½ø³Ì£¨»òÕ߸¸½ø³Ì£©µÄÖնˡ£´øÎʺŵĽø³ÌÎÞ¿ØÖÆÖնˣ¨Í¨³£ÎªÏµÍ³½ø³Ì£©
TIME ×Ô½ø³ÌÆô¶¯ÒÔÀ´Õ¼CPUʱ¼ä×ÜÁ¿
COMD ²úÉú½ø³ÌµÄÃüÁî
9¡¢Ê¹ÓÃps±¨¸æ¡£

²éÕÒÊôÓÚÒ»¸öÓû§µÄÐí¶àÏàͬµÄ¹¤×÷¡£KillÃüÁîÖÕÖ¹½ø³Ì¡£ ps -U username
²éÕÒTIME×Ö¶ÎÖÐÕ¼ÓÃÁ˺ܶàCPUʱ¼äµÄ½ø³Ì¡£ÕâÑùµÄ½ø³Ì¿ÉÄÜÔÚËÀÑ­»·¡£ps -e
²éÕÒC×Ö¶Î,ÕÒ³ö²»ÖØÒªµ«Õ¼ÓÃÁË´óÁ¿CPUʱ¼äµÄ½ø³Ì¡£Èç¹û¸Ã½ø³Ì»ñÈ¡¹ý¶àÄڴ棬ɾ³ý¸Ã½ø³Ì¡£Èç¹ûÐí¶à½ø³ÌÕ¼ÓÃÁË´óÁ¿Äڴ棬Ôòϵͳ¿ÉÄÜÐèÒªÔö¼ÓÄÚ´æ¡£ps -el
×¢ÒâʹÓÃÔ½À´Ô½¶àCPUʱ¼äµÄʧ¿Ø½ø³Ì¡£¿ÉÒÔͨ¹ýʹÓÃ-fÑ¡Ïî²é¿´½ø³ÌÆô¶¯Ê±¼ä£¨STIME)ÒÔ¼°Í¨¹ý²é¿´TIME×Ö¶ÎÖеÄCPUʱ¼ä×ÜÁ¿À´¼ì²âʧ¿Ø½ø³Ì¡£ ps -f
10¡¢É¾³ý½ø³Ì¡£
ÔÚÕý³£Í¾¾¶ÎÞ·¨½áÊøʱ²ÅʹÓÃɾ³ýÃüÁî¡£
#kill - signal pid
signal£º57
signal£º
2 ÖжÏ
3 Í˳ö
4 ·Ç·¨Ö¸Áî
5 ¸ú×ÙÖжÏ
6 Abort
7 EMTÖ¸ÁEmulation¾ºÕùtrap£©
8 ¸¡µã¸ñʽµÄÒì³£Çé¿ö
9 kill£¨²»Äܱ»²¶»ñ»òºöÂÔ£©
10 ͨµÀ´íÎó
11²»ºÏ·¨µÄÄÚ´æÇø¶Î
12 ´íÎóϵͳµ÷ÓÃ
13 дÈë²»¿É¶ÁµÄÁ¬Í¨¹ÜµÀ
14 alarm clock
15 Èí¼þ½áÊøÐźÅ
16 Óû§¶¨ÒåµÄÐźÅ1
17Óû§¶¨ÒåµÄÐźÅ2
18 ×Ó½ø³Ì״̬±»¸Ä±ä
19 µçÔ´»µµô
20´°¿Ú£¨Window)µÄ´óС±»¸Ä±ä
21Urgent(½ô¼±µÄ£© Socket Condition
22 Pollable£¨¿É²éѯµÄ£©event
23 ֹͣ
24 ÓÉÓû§ÖÕÖ¹
25 ¼ÌÐøÖ´ÐÐ
26 Í£Ö¹ÖÕ¶ËÊäÈë
27 Í£Ö¹ÖÕ¶ËÊä³ö
28 virtual Timer expired
29 Profiling time expired
30 ³¬¹ýCPUʱ¼ä
31 ³¬¹ýÎļþ´óСÏÞÖÆ
32 Socket I/O possible
ÓÐʱ¼´Ê¹ÓÃkillÃüÁµ«½ø³ÌÈÔδ±»É¾³ý¡£×îÓпÉÄܵÄÈýÖÖÇé¿ö£º
½ø³ÌÔÚÍ˳öÇ°µÈ´ýÉ豸Íê³É²Ù×÷¡£
½ø³ÌÔڵȴýÓÉÓÚNFS¹ÊÕ϶øµ¼ÖµÄÎÞ·¨Ê¹ÓõÄ×ÊÔ´¡£ÒªÉ¾³ý´ËÀà½ø³Ì£¬ÊäÈëkill -quit PID
½ø³ÌΪ½©ËÀ½ø³Ì£¬ÔÚps±¨¸æµÄdefunctµÄÏûÏ¢ÖÐÏÔʾ¡£½©ËÀ½ø³ÌÊÇÊÍ·ÅÁËËùÓÐ×ÊÔ´£¬µ«Î´½ÓÊܵ½¸¸½ø³ÌÈ·ÈϵĽø³Ì¡£Ö»ÓÐÊÕµ½È·ÈϲÅɾ³ý½ø³ÌÔÚ½ø³Ì±íÖеÄÈë¿Ú¡£ÏÂÒ»´ÎÒýµ¼Ê±½©ËÀ½ø³Ì»á±»Çå³ý¡£½©ËÀ½ø³Ì²»Ó°ÏìϵͳÐÔÄÜ£¬²»ÐèҪɾ³ý¡£
11¡¢ÓÅÏÈȨ¿ØÖÆÃü

ʹÓÃpriocntlÃüÁî¿ÉÒÔ£º
ÏÔʾ»òÉèÖÃÖ¸¶¨½ø³ÌµÄµ÷¶È²Î
ÏÔʾϵͳµ÷¶È³ÌÐòµÄµ±Ç°ÅäÖÃÐÅÏ¢
Ö´ÐдøÓÐÖ¸¶¨µ÷¶È²ÎÊýµÄÃüÁî
ÿ¸ö½ø³Ì¶¼Óв»Í¬µÄ¼¶£¬Ã¿¼¶·ÖÅäÓи÷×Ô²»Í¬µÄµ÷¶È²ßÂÔ¡£
ϵͳ¿ÉÄÜÅäÖõļ¶°üÀ¨£º
ϵͳ£¨SYS)
½»»¥(IA)
ʵʱ(RT)
·Öʽ¹²Ïí(TS)
¶ÔÓÚ·Öʽ¹²Ïí¼¶£¬Óû§ÌṩµÄÓÅÏÈȨ·¶Î§Îª£º-20~+20¡£Ò»¸ö
·Öʱ¹²Ïí½ø³ÌµÄÓÅÏÈȨ£¨Óû§Ä£Ê½ÓÅÏÈȨ£©ÊÇ´Ó¸¸½ø³Ì¼Ì³Ð
¶øÀ´¡£ÏµÍ³ÔÚ·Öʱµ÷¶È±íÖвéÕÒÓû§Ä£Ê½ÓÅÏÈȨ£¬¼ÓÈëÈκÎ
niceÖµ»òÕâÕßpriocntlÓÅÏÈȨֵ£¨Óû§Ìṩ£©£¬±£Ö¤´´½¨µÄÈ«
¾ÖÓÅÏÈȨÔÚ0~59Ö®¼ä¡£
ÔÚĬÈÏÅäÖÃÖУ¬Ò»¸ö¿ÉÔËÐеÄʵʱ½ø³ÌÔÚÈκÎÆäËü½ø³Ì֮ǰÔËÐС£ÊµÊ±½ø³ÌʹÓò»µ±»áµ¼ÖÂϵͳÐÔÄܼ±¾çϽµ¡£
1. ÏÔʾ½ø³Ì¼¶µÄ»ù±¾ÐÅÏ¢£¨½ø³Ì¼¶»òϵͳµ÷¶È²ÎÊý£©:
ÊäÈëpriocntl -l²¢»Ø³µ
2. ÏÔʾ½ø³ÌµÄÈ«¾ÖÓÅÏȼ¶
ʹÓÃps -eclÃüÁîÏÔʾ½ø³ÌµÄÈ«¾ÖÓÅÏÈȨ¡£È«¾ÖÓÅÏÈȨÔÚPRIÀ¸Áгö
3¡¢Ö¸¶¨½ø³ÌµÄÓÅÏȼ¶£º
ÊäÈëpriocntl -e -c class -m user -limit -p priority command - name»Ø³µ
-e Ö´ÐÐÃüÁî
-c Ö¸¶¨¼¶£¨Ä¬ÈÏÑ¡ÏîÊÇTS£¨·Öʱ¹²Ïí£©»òRI£¨ÊµÊ±£©
-m Óû§ÏÞÖÆÑ¡Ïָ¶¨-pÑ¡ÏîÌáÉý»ò½µµÍÓÅÏÈȨµÄ×î´óÁ¿¡£
-p ÔÊÐíÖ¸¶¨Óû§ÌṩµÄÓÅÏÈȨ£¬·¶Î§Îª-20~+20¡£
4.¸ü¸Ä·Öʱ¹²Ïí½ø³ÌµÄµ÷¶È²ÎÊý
ÒÀÕÕÒÔϲ½Öè¸ü¸Ä·Öʱ¹²Ïí½ø³ÌµÄµ÷¶È²ÎÊý£º
1£©³ÉΪ³¬¼¶Óû§¡£
2£©ÊäÈëpriocntl -s -m user -limit [-p priority] -i id type id -list»Ø³µ¡£
-sÔÊÐíÉèÖÃÓû§ÓÅÏÈȨ·¶Î§µÄÉÏÏÞ
-m Óû§ÏÞÖÆÑ¡Ïָ¶¨-pÑ¡ÏîÌáÉý»ò½µµÍÓÅÏÈȨµÄ×î´óÁ¿¡£
-pÓÅÏÈȨÃüÁîÃûÑ¡ÏÔÊÐíÖ¸¶¨ÓÅÏÈȨ¡£
-I id -typeºÍid -listÑ¡ÏîʹÓÃid -typeºÍid -listµÄ×éºÏ±êʶ½ø³Ì£¬ id -
typeÖ¸¶¨idÀàÐÍ£¬ÈçPID»òUID¡£
3£©ÊäÈëps -ecl|grep id -list»Ø³µ¡£
4£©¼ì²éPRIÀ¸µÄÊä³ö£¬ÑéÖ¤ÒѾ­³É¹¦µØ¸ü¸ÄÁ˽ø³Ì״̬¡£
% priocntl -s -c RT -t 500 -p 20 myprog
% ps -ecl|grep myprog
5. ¸ü¸Ä½ø³Ì
ÒÀÕÕÒÔϲ½Öè¸ü¸Ä½ø³Ì¼¶£º
1£©³ÉΪ³¬¼¶Óû§¡£
2£©ÊäÈëpriocntl -s -c class -i id type id -list»Ø³µ¡£
-sÔÊÐíÉèÖÃÓû§ÓÅÏÈȨ·¶Î§µÄÉÏÏÞ²¢¸ü¸ÄÓÅÏÈȨ
-c Ö¸¶¨Ïë¸ü¸ÄµÄ½ø³Ì¼¶ÎªTS£¨·Öʱ¹²Ïí£©¼¶»òRI£¨ÊµÊ±£©¼¶
-I id -typeºÍid -listÑ¡ÏîʹÓÃid -typeºÍid -listµÄ×éºÏ±êʶ½ø³Ì£¬ id -typeÖ¸¶¨id
ÀàÐÍ£¬ÈçPID»òUID¡£
3£©ÊäÈëps -ecl|grep id -list»Ø³µ¡£
4£©¼ì²éPRIÀ¸µÄÊä³ö£¬ÑéÖ¤ÒѾ­³É¹¦µØ¸ü¸ÄÁ˽ø³Ì״̬¡£
×¢Ò⣺±ØÐëÊdz¬¼¶Óû§»òÕßÔÚʵʱshellÖвÙ×÷£¬¸ü¸Ä½ø³Ì¼¶Îª·Çʵʱ¼¶»òÕßʵʱ¼¶¡£
6¡¢¸ü¸Ä½ø³ÌÓÅÏȼ¶
ʹÓÃniceÃüÁî¿ÉÒÔÌá¸ß»ò½µµÍÒ»¸öÃüÁî»ò½ø³ÌµÄÓÅÏÈȨ¡£
²»´ø²ÎÊýʹÓøÃÃüÁîÔòĬÈÏniceÖµÔö4¸öµ¥Î»£¬Ê¹½ø³ÌÓÅÏÈ
Ȩ½µµÍ¡£
×¢Ò⣺±ØÐëÊdz¬¼¶Óû§²ÅÄÜ¡£
/usr/bin/nice command -name(ĬÈÏ£¬½ø³ÌµÄÓÅÏÈȨ½µµÍ4¸öµ¥Î»£©
/usr/bin/nice +10 command -name£¨½ø³ÌµÄÓÅÏÈȨ½µµÍ10¸öµ¥Î»£©
/usr/bin/nice -10 command -name£¨½ø³ÌµÄÓÅÏÈȨÔö¼Ó10¸öµ¥Î»£©
/usr/bin/nice - -10 command -name£¨nice Öµ¼õÉÙ10¸öµ¥Î»£¬Ìá¸ßÒ»¸öÃüÁîµÄÓÅÏÈȨ£©
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ