linuxϵͳÈÕÖ¾ÔõôÉó²é
ÔõÑùÉó²é linux ϵͳÈÕÖ¾£¿Ê¹Óà “journalctl” ÏÂÁîʵʱÉó²é¡¢×¼Ê±¼ä¹ýÂË»ò °´µ¥Î»ºÍÐÂΞÙÐйýÂË¡£Éó²éÄں˻·»º³åÇøµÄÔçÆÚÖ¸µ¼ÐÂÎÅ£¬Ê¹Óà “dmesg” ÏÂÁî¡£Éó²éÒѵÇÈÎÃü»§µÄÁÐ±í£¬Ê¹Óà “lastlog” ÏÂÁʹÓà “tail -f /var/log/syslog” »ò “less /var/log/messages” ÒÔ·ÖÒ³·½·¨Éó²éÈÕÖ¾ÎļþµÄʵʱÁ÷¡£
Linux ϵͳÈÕÖ¾Éó²éÖ¸ÄÏ
ÔÚ Linux ϵͳÖУ¬ÈÕÖ¾Îļþ¼Í¼ÁËϵͳÊÂÎñ¡¢¹ýʧºÍ²Ù×÷¡£Éó²éÈÕÖ¾Îļþ¹ØÓÚ¹ÊÕÏɨ³ýºÍϵͳά»¤ºÜÊÇÖ÷Òª¡£
ÔõÑùÉó²é Linux ϵͳÈÕÖ¾
×î³£ÓõÄÏÂÁîÊÇ journalctl£º
ʵʱÉó²éÈÕÖ¾£º journalctl -f
׼ʱ¼äÉó²éÈÕÖ¾£º journalctl –since “timestamp”£¨ÀýÈç journalctl –since “2023-03-08 16:00:00″£©
µ¥Î»¹ýÂË£º journalctl | grep unit_name£¨ÀýÈç journalctl | grep sshd£©
ÐÂÎŹýÂË£º journalctl | grep “error message”
ÆäËûÓÐÓõÄÏÂÁî
dmesg£º Éó²éÄں˻·»º³åÇøÖеÄÔçÆÚÖ¸µ¼ÐÂÎÅ¡£
lastlog£º Éó²éÒѵÇÈÎÃü»§µÄÁÐ±í¡£
tail -f /var/log/syslog£º Éó²éϵͳÈÕÖ¾ÎļþµÄʵʱÁ÷¡£
less /var/log/messages£º ÒÔ·ÖÒ³·½·¨Éó²éÐÂÎÅÈÕÖ¾¡£
ÈÕÖ¾ÎļþλÖÃ
Linux ϵͳµÄÈÕÖ¾Îļþͨ³£Î»ÓÚÒÔÏÂĿ¼£º
/var/log£ºÖ÷ÒªµÄÈÕÖ¾ÎļþĿ¼¡£
/var/log/messages£ºÏµÍ³ÐÂÎÅÈÕÖ¾¡£
/var/log/kern.log£ºÄÚºËÈÕÖ¾¡£
/var/log/auth.log£ºÊÚȨºÍÉí·ÝÑéÖ¤ÈÕÖ¾¡£
/var/log/syslog£ºÏµÍ³ÈÕÖ¾µÄ·ûºÅÁ´½Ó£¬Ö¸Ïò /var/log/messages¡£
¸ß¼¶Ñ¡Ïî
ʹÓÃÈÕÖ¾¼¶±ð£º journalctl -l£¨ÀýÈç journalctl -l err£©
°´ pid ¹ýÂË£º journalctl _PID=1234
»º³åÇøת¶¯£º journalctl –rotate
ɨ³ýÈÕÖ¾£º journalctl –vacuum-time=”2 weeks”
ÒÔÉϾÍÊÇlinuxϵͳÈÕÖ¾ÔõôÉó²éµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡