linuxÔõÑùÉó²é¾ç±¾Àú³ÌÊÇ·ñ±£´æ
linuxÉó²é¾ç±¾Àú³ÌÊÇ·ñ±£´æµÄÒªÁìÓУº1¡¢Ê¹ÓÃpsÏÂÁÁгöÄ¿½ñÔËÐеÄÀú³Ì£¬Í¨¹ýgrepÏÂÁî¹ýÂ˳öÓë½ÅÄÚÇé¹ØµÄÀú³Ì£¬²¢¼ì²éÊÇ·ñ±£´æ£»2¡¢Ê¹ÓÃpgrepÏÂÁͨ¹ýÀú³ÌµÄÃû³Æ²éÕÒÆäÀú³Ìid£»3¡¢Ê¹ÓÃpidofÏÂÁͨ¹ýÀú³ÌµÄÃû³ÆÖ±½Ó²éÕÒÀú³Ìid¡£
±¾½Ì³Ì²Ù×÷ϵͳ£ºLinux5.18.14ϵͳ¡¢Dell G3µçÄÔ¡£
ÔÚLinuxÖУ¬¿ÉÒÔʹÓöàÖÖÒªÁìÀ´Éó²é¾ç±¾Àú³ÌÊÇ·ñ±£´æ¡£ÒÔÏÂÊǼ¸ÖÖ³£¼ûµÄÒªÁ죺
1¡¢Ê¹ÓÃpsÏÂÁpsÏÂÁî¿ÉÒÔÁгöÄ¿½ñÔËÐеÄÀú³Ì¡£Äã¿ÉÒÔͨ¹ýgrepÏÂÁî¹ýÂ˳öÓë½ÅÄÚÇé¹ØµÄÀú³Ì£¬²¢¼ì²éÊÇ·ñ±£´æ¡£ÀýÈ磬¼ÙÉè¾ç±¾ÃûΪscript.sh£¬Äã¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´¼ì²éÀú³ÌÊÇ·ñ±£´æ£º
ps aux | grep script.sh
µÇ¼ºó¸´ÖÆ
ÈôÊÇÊä³öÖаüÀ¨Óë½ÅÄÚÇé¹ØµÄÀú³Ì£¬ÔòÌåÏÖÀú³Ì±£´æ¡£
2¡¢Ê¹ÓÃpgrepÏÂÁpgrepÏÂÁî¿ÉÒÔͨ¹ýÀú³ÌµÄÃû³Æ²éÕÒÆäÀú³ÌID¡£Äã¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´¼ì²é¾ç±¾Àú³ÌÊÇ·ñ±£´æ£º
pgrep -f script.sh
µÇ¼ºó¸´ÖÆ
ÈôÊÇÏÂÁî·µ»ØÒ»¸öÀú³ÌID£¬ÔòÌåÏÖÀú³Ì±£´æ¡£
3¡¢Ê¹ÓÃpidofÏÂÁpidofÏÂÁî¿ÉÒÔͨ¹ýÀú³ÌµÄÃû³ÆÖ±½Ó²éÕÒÀú³ÌID¡£Äã¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´¼ì²é¾ç±¾Àú³ÌÊÇ·ñ±£´æ£º
pidof script.sh
µÇ¼ºó¸´ÖÆ
ÈôÊÇÏÂÁî·µ»ØÒ»¸öÀú³ÌID£¬ÔòÌåÏÖÀú³Ì±£´æ¡£
ƾ֤ÏêϸÇéÐΣ¬Ñ¡ÔñÊʺϵÄÒªÁìÀ´¼ì²é¾ç±¾Àú³ÌÊÇ·ñ±£´æ¡£ÕâЩҪÁìÒ²¿ÉÒÔͨ¹ý±à³ÌÓïÑÔ£¨ÈçC¡¢Python£©µÄϵͳŲÓûò¿âº¯ÊýÀ´ÊµÏÖ¡£
ÒÔÉϾÍÊÇlinuxÔõÑùÉó²é¾ç±¾Àú³ÌÊÇ·ñ±£´æµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡