ÔõÑùʹÓÃLinux¾ÙÐÐÀú³ÌÖÎÀíºÍµ÷ÓÅ
ÔõÑùʹÓÃlinux¾ÙÐÐÀú³ÌÖÎÀíºÍµ÷ÓÅ
ÔÚLinux²Ù×÷ϵͳÖУ¬Àú³ÌÖÎÀíºÍµ÷ÓÅÊǺÜÊÇÖ÷ÒªµÄʹÃü¡£Í¨¹ýÓÐÓõØÖÎÀíÀú³Ì£¬ÎÒÃÇ¿ÉÒÔÌá¸ßϵͳµÄÐÔÄÜ£¬²¢È·±£ÏµÍ³µÄÎȹÌÔËÐС£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃlinux¾ÙÐÐÀú³ÌÖÎÀíºÍµ÷ÓÅ£¬²¢Ìṩ´úÂëʾÀý¡£
Ò»¡¢Àú³ÌÖÎÀí
1.Éó²éÕýÔÚÔËÐеÄÀú³Ì
ÒªÉó²éÕýÔÚÔËÐеÄÀú³Ì£¬ÎÒÃÇ¿ÉÒÔʹÓÃpsÏÂÁî¡£ÒÔÏÂÊÇһЩ³£ÓõÄpsÏÂÁîÑ¡Ï
ps -ef£ºÏÔʾËùÓÐÀú³ÌµÄÏêϸÐÅÏ¢¡£
ps aux£ºÏÔʾËùÓÐÀú³ÌµÄÏêϸÐÅÏ¢£¬°üÀ¨ÆäËûÓû§µÄÀú³Ì¡£
ps -e | grep process_name£ºÏÔʾָ¶¨Àú³ÌÃûµÄÀú³Ì¡£
ʾÀý´úÂ룺
ps -ef
µÇ¼ºó¸´ÖÆ
2.ɱËÀÀú³Ì
ɱËÀÒ»¸öÀú³ÌÒâζ×ÅÖÕÖ¹Ò»¸öÕýÔÚÔËÐеÄÀú³Ì¡£ÎÒÃÇ¿ÉÒÔʹÓÃkillÏÂÁîÀ´É±ËÀÀú³Ì¡£ÒÔÏÂÊÇһЩ³£ÓõÄkillÏÂÁîÑ¡Ï
kill pid£ºÉ±ËÀÖ¸¶¨PIDµÄÀú³Ì¡£
killall process_name£ºÉ±ËÀÖ¸ÃüÃû³ÆµÄËùÓÐÀú³Ì¡£
pkill process_name£ºÉ±ËÀÖ¸ÃüÃû³ÆµÄÀú³Ì¡£
ʾÀý´úÂ룺
kill 1234
µÇ¼ºó¸´ÖÆ
3.Æô¶¯ºǫ́Àú³Ì
ÓÐʱ¼äÎÒÃÇÏ£Íû½«Ä³¸öÀú³ÌÔÚºǫ́ÔËÐУ¬ÒÔ±ãÎÒÃÇ¿ÉÒÔ¼ÌÐøÔÚÖÕ¶ËÖÐÖ´ÐÐÆäËûʹÃü¡£ÎÒÃÇ¿ÉÒÔʹÓÃ&·ûºÅÀ´½«Àú³Ì·Åµ½ºǫ́ÔËÐС£
ʾÀý´úÂ룺
./my_program &
µÇ¼ºó¸´ÖÆ
4.Àú³ÌÓÅÏȼ¶
LinuxϵͳÖеÄÿ¸öÀú³Ì¶¼ÓÐÒ»¸öÓÅÏȼ¶¡£ÎÒÃÇ¿ÉÒÔͨ¹ýniceÏÂÁîÀ´¸Ä±äÀú³ÌµÄÓÅÏȼ¶¡£
ʾÀý´úÂ룺
nice -n 10 my_program
µÇ¼ºó¸´ÖÆ
5.ÊØ»¤Àú³Ì
ÊØ»¤Àú³ÌÊÇÔÚºǫ́ÔËÐеÄÀú³Ì£¬Í¨³£ÓÃÓÚ³¤Ê±¼äÔËÐеÄЧÀÍ¡£ÎÒÃÇ¿ÉÒÔʹÓÃdaemonÏÂÁÀú³Ìת»»ÎªÊØ»¤Àú³Ì¡£
ʾÀý´úÂ룺
daemon my_program
µÇ¼ºó¸´ÖÆ
¶þ¡¢Àú³Ìµ÷ÓÅ
1.Éó²éÀú³Ì×ÊԴʹÓÃÇéÐÎ
ÒªÉó²éÀú³ÌµÄ×ÊԴʹÓÃÇéÐΣ¬ÎÒÃÇ¿ÉÒÔʹÓÃtopÏÂÁî¡£topÏÂÁî¿ÉÒÔʵʱµØÏÔʾϵͳÖи÷¸öÀú³ÌµÄCPUºÍÄÚ´æʹÓÃÇéÐΡ£
ʾÀý´úÂ룺
top
µÇ¼ºó¸´ÖÆ
2.ÉèÖÃÀú³ÌÓÅÏȼ¶ºÍµ÷ÀíÕ½ÂÔ
ÎÒÃÇ¿ÉÒÔʹÓÃniceÏÂÁîºÍchrtÏÂÁîÀ´ÉèÖÃÀú³ÌµÄÓÅÏȼ¶ºÍµ÷ÀíÕ½ÂÔ¡£
ʾÀý´úÂ룺
nice -n -20 my_program chrt --rr 99 my_program
µÇ¼ºó¸´ÖÆ
3.¼à¿Øϵͳ¸ºÔØ
ϵͳ¸ºÔØÊÇָϵͳÖÐÕýÔÚÔËÐеÄÀú³ÌÊýÄ¿¡£ÎÒÃÇ¿ÉÒÔʹÓÃuptimeÏÂÁîÀ´Éó²éϵͳµÄ¸ºÔØÇéÐΡ£
ʾÀý´úÂ룺
uptime
µÇ¼ºó¸´ÖÆ
4.ÏÞÖÆÀú³Ì×ÊԴʹÓÃ
ÓÐʱ¼äÎÒÃÇÐèÒªÏÞÖÆij¸öÀú³Ì¿ÉÒÔʹÓõÄ×ÊÔ´¡£ÎÒÃÇ¿ÉÒÔʹÓÃulimitÏÂÁîÀ´ÉèÖÃÀú³ÌµÄ×ÊÔ´ÏÞÖÆ¡£
ʾÀý´úÂ룺
ulimit -u 100
µÇ¼ºó¸´ÖÆ
×ܽ᣺
Àú³ÌÖÎÀíºÍµ÷ÓÅÊÇLinuxϵͳÖкÜÊÇÖ÷ÒªµÄʹÃü¡£Í¨¹ýºÏÀíµØÖÎÀíºÍµ÷½âÀú³Ì£¬ÎÒÃÇ¿ÉÒÔÌá¸ßϵͳµÄÐÔÄܺÍÎȹÌÐÔ¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÏÈÈÝÁËÔõÑùʹÓÃlinux¾ÙÐÐÀú³ÌÖÎÀíºÍµ÷ÓÅ£¬ÌṩÁËһЩ³£ÓõÄÏÂÁîºÍ´úÂëʾÀý¡£Ï£Íû±¾ÎĶÔÄúÔÚʹÓÃLinux¾ÙÐÐÀú³ÌÖÎÀíºÍµ÷ÓÅ·½ÃæÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇÔõÑùʹÓÃLinux¾ÙÐÐÀú³ÌÖÎÀíºÍµ÷ÓŵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡