×ðÁú¿­Ê±¹ÙÍøµÇ¼

linuxÔõôÉó²éÀú³ÌµÄpid

ÔõÑùÉó²é linux Àú³ÌµÄ pid

ÔÚ Linux ϵͳÖÐ £¬Àú³Ì±êʶ·û (PID) ÊÇÒ»¸öΨһµÄÕûÊýÖµ £¬ÓÃÓÚ±êʶÕýÔÚÔËÐеÄÀú³Ì¡£ÒªÉó²éÀú³ÌµÄ PID £¬Óм¸ÖÖÒªÁ죺

1. ʹÓà pidof ÏÂÁî

pidof ÏÂÁî°´Ãû³Æ²éÕÒÀú³ÌµÄ PID¡£ÀýÈç £¬Òª²éÕÒÃûΪ firefox µÄÀú³ÌµÄ PID £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

$ pidof firefox

µÇ¼ºó¸´ÖÆ

Õ⽫´òÓ¡Àú³ÌµÄ PID£º

12345

µÇ¼ºó¸´ÖÆ

2. ʹÓà pgrep ÏÂÁî

pgrep ÏÂÁîƾ֤ģʽ»ò³ÌÐòÃûËÑË÷ÕýÔÚÔËÐеÄÀú³ÌµÄ PID¡£ÀýÈç £¬Òª²éÕÒÒÔ×Öĸ¡°f¡±¿ªÍ·µÄËùÓÐÀú³ÌµÄ PID £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

$ pgrep -f f

µÇ¼ºó¸´ÖÆ

Õ⽫´òÓ¡ËùÓÐÆ¥ÅäÀú³ÌµÄ PID ÁÐ±í£º

12345
56789

µÇ¼ºó¸´ÖÆ

3. ʹÓà ps ÏÂÁî

ps ÏÂÁîÁгöϵͳÖеÄÀú³Ì¡£ÒªÉó²éÀú³ÌµÄ PID £¬¿ÉÒÔʹÓÃÒÔÏÂÑ¡Ï

$ ps -p <pid></pid>

µÇ¼ºó¸´ÖÆ

ÀýÈç £¬ÒªÉó²é PID Ϊ 12345 µÄÀú³Ì £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

$ ps -p 12345

µÇ¼ºó¸´ÖÆ

Õ⽫´òÓ¡ÓйظÃÀú³ÌµÄÐÅÏ¢ £¬°üÀ¨Æä PID£º

UID        PID  PPID  C STIME          TTY          TIME CMD
user1    12345 12344  0 14:31:23 ?        00:00:00 firefox

µÇ¼ºó¸´ÖÆ

4. Éó²é /proc Ŀ¼

/proc Ŀ¼°üÀ¨ÓйØÕýÔÚÔËÐÐÀú³ÌµÄÐÅÏ¢¡£Ã¿¸öÀú³Ì¶¼ÓÐÒ»¸öÒÔÆä PID ÃüÃûµÄ×ÓĿ¼¡£ÀýÈç £¬ÒªÉó²é PID Ϊ 12345 µÄÀú³ÌµÄÐÅÏ¢ £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

$ cd /proc/12345

µÇ¼ºó¸´ÖÆ

ÔÚ¸Ã×ÓĿ¼ÖÐ £¬¿ÉÒÔÕÒµ½ÓйØÀú³ÌµÄÖÖÖÖÐÅÏ¢ £¬°üÀ¨Æä PID£º

$ cat stat
...
Pid: 12345
...

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇlinuxÔõôÉó²éÀú³ÌµÄpidµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ