尊龙凯时人生就是搏

ÔõÑù¾ÙÐÐLinuxϵͳµÄÈÕÖ¾ÍøÂçºÍÆÊÎö

ÔÚLinuxϵͳÖУ¬ÈÕÖ¾ÊǺÜÊÇÖ÷ÒªµÄ£¬Ëü¿ÉÒԼͼϵͳ±¬·¢µÄÈκÎÊÂÎñ£¬ÈçÈí¼þ³ÌÐòÔËÐÐÇéÐΡ¢ÍøÂçÅþÁ¬ÇéÐΡ¢ÏµÍ³¹ÊÕϵÈ¡£ÈÕÖ¾¼Í¼µÄÐÅÏ¢¿ÉÒÔ×ÊÖúÖÎÀíÔ±¸üºÃµØÏàʶϵͳÔËÐÐÇéÐΣ¬²éÕÒϵͳ¹ÊÕÏ¡£Òò´Ë£¬ÈÕÖ¾µÄÍøÂçºÍÆÊÎö¹ØÓÚLinuxϵͳÖÎÀíÔ±À´ËµÊǺÜÊÇÖ÷ÒªµÄ¡£

±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃÈÕÖ¾ÖÎÀí¹¤¾ßlogrotateºÍlogwatch¾ÙÐÐÈÕÖ¾ÍøÂçºÍÆÊÎö£¬²¢ÌṩһЩÏêϸµÄ´úÂëʾÀý¡£

ÈÕÖ¾ÍøÂç

ÔÚLinuxϵͳÖУ¬ÏµÍ³ÈÕ־ͨ³£´æ´¢ÔÚ/var/logĿ¼Ï¡£ÕâЩÈÕÖ¾Îļþ¿ÉÒÔÊÇϵͳЧÀ͵ÄÈÕÖ¾£¬Ò²¿ÉÒÔÊÇÓ¦ÓóÌÐòµÄÈÕÖ¾¡£

ΪÁË׼ȷµØÍøÂçºÍÖÎÀíÈÕÖ¾Îļþ£¬ÎÒÃÇ¿ÉÒÔʹÓÃlogrotateÕâ¸öÈÕÖ¾ÖÎÀí¹¤¾ß¡£logrotate¿ÉÒÔ×ÊÖúÎÒÃÇ×Ô¶¯Ñ¹Ëõ¡¢¹éµµºÍɾ³ýÎôÈÕÖ¾Îļþ£¬ÒÔ¼°°´ÆÚ½¨ÉèеÄÈÕÖ¾Îļþ¡£ÏÂÃæÊÇÒ»¸ölogrotateµÄÉèÖÃÎļþʾÀý£º

# /etc/logrotate.d/mylog

/var/log/mylog {
  daily
  missingok
  rotate 7
  compress
  delaycompress
  sharedscripts
  postrotate
    /bin/systemctl restart rsyslog.service >/dev/null 2>&1 || true
  endscript
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÎļþÖÐ:

daily: ÌìÌìÂÖתһԽÈÕÖ¾Îļþ

missingok: ÈôÊÇÈÕÖ¾Îļþ²»±£´æ£¬²»»á±¨´í

rotate 7: ±£´æ7¸öÎôÈÕÖ¾Îļþ

compress: ѹËõÈÕÖ¾Îļþ

delaycompress: ÑÓ³ÙѹËõ£¬´øÓÐ .1 µÄÈÕÖ¾Îļþ²»»á±»Ñ¹Ëõ

sharedscripts: ÔÚËùÓо籾ִÐÐ֮ǰִÐÐ postrotate ºÍ endscript ¾ç±¾

postrotate: ÔÚÈÕÖ¾ÂÖת֮ºóÖ´Ðеľ籾£¬±¾ÀýÖÐÊÇÖØÆô rsyslog ЧÀÍ

endscript: postrotate ¾ç±¾¿¢Êµıê¼Ç

ͨ¹ýlogrotateÉèÖÃÎļþ£¬ÎÒÃÇ¿ÉÒÔ°´ÆÚÕûÀíÓâÆÚµÄÈÕÖ¾Îļþ£¬²¢½«ÈÕÖ¾ÎļþѹËõºÍ´æµµ¡£½ÓÏÂÀ´ÎÒÃǾͿÉÒÔʹÓÃlogwatch¹¤¾ßÀ´¶ÔÈÕÖ¾¾ÙÐмà¿ØºÍÆÊÎö¡£

ÈÕÖ¾ÆÊÎö

logwatchÊÇÒ»¿îÈÕÖ¾ÆÊÎö¹¤¾ß£¬ËüÄܹ»×Ô¶¯ÌìÉúÈÕÖ¾ÕªÒª±¨¸æ£¬²¢½«ÕâЩ±¨¸æͨ¹ýÓʼþ·¢Ë͸øÖÎÀíÔ±¡£ÒªÊ¹ÓÃlogwatch£¬ÎÒÃÇÐèÒªÏÈ×°ÖÃËü£¬È»ºóÉèÖÃËüµÄÓʼþ֪ͨÉèÖá£ÏÂÃæÊÇÒ»¸öÏêϸµÄÀý×Ó£º

Ê×ÏÈÎÒÃÇÐèҪͨ¹ýÒÔÏÂÏÂÁî×°ÖÃlogwatch£º

$ sudo apt-get install logwatch

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³ÉÖ®ºó£¬ÎÒÃÇÐèÒª¶Ôlogwatch¾ÙÐÐÉèÖá£ÉèÖÃÎļþλÓÚ/etc/logwatch/conf/Ŀ¼Ï¡£ÎÒÃÇ¿ÉÒÔʹÓÃĬÈÏÉèÖÃÎļþ£¬Ò²¿ÉÒÔƾ֤×Ô¼ºµÄÐèÒª¾ÙÐÐÐ޸ġ£ÏÂÃæ¸ø³öÒ»¸ö¼òÆÓµÄÉèÖÃʾÀý£º

# /etc/logwatch/conf/logwatch.conf

MailTo = user@example.com   # ·¢ËÍÈÕÖ¾±¨¸æµÄÓʼþµØµã
MailFrom = logwatch@example.com  # ·¢ËÍÈÕÖ¾±¨¸æµÄ·¢¼þÈ˵صã
Range = yesterday   # ͳ¼ÆÈÕÖ¾±¨¸æµÄʱ¼ä¶Î£¬±¾ÀýÖÐÊÇ×òÌìµÄÈÕÖ¾
Detail = High    # ±¨¸æµÄÏêϸˮƽ£¬±¾ÀýÖÐÊǸß

µÇ¼ºó¸´ÖÆ

ÉèÖÃÍê³ÉÖ®ºó£¬ÎÒÃǾͿÉÒÔʹÓÃlogwatch¹¤¾ßÀ´ÌìÉúÈÕÖ¾±¨¸æÁË¡£ÏÂÃæÊÇÒ»¸öÏêϸµÄʾÀý£º

$ sudo logwatch --output mail --range yesterday --detail high --mailto user@example.com --subject ¡°Daily Logwatch Report¡± --service all

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÏÂÁîÖУº

–output mail: ½«ÈÕÖ¾±¨¸æͨ¹ýÓʼþ·¢ËÍ

–range yesterday: ͳ¼Æ×òÌìµÄÈÕÖ¾

–detail high: ÌìÉúÏêϸµÄÈÕÖ¾±¨¸æ

–mailto user@example.com: ·¢ËÍÈÕÖ¾±¨¸æµÄÓʼþµØµã

–subject ¡°Daily Logwatch Report¡±: ÈÕÖ¾±¨¸æÓʼþµÄÖ÷Ìâ

–service all: ͳ¼ÆËùÓеÄЧÀÍÈÕÖ¾

ͨ¹ýÒÔÉÏÏÂÁÎÒÃÇ¿ÉÒÔÌìÉúÏêϸµÄÈÕÖ¾±¨¸æ£¬²¢Í¨¹ýÓʼþ·¢Ë͸øÖÎÀíÔ±¡£

½áÓï

ͨ¹ýlogrotateºÍlogwatch¹¤¾ß£¬ÎÒÃÇ¿ÉÒÔºÜÀû±ãµØ¾ÙÐÐLinuxϵͳÈÕÖ¾µÄÍøÂçºÍÆÊÎö¡£Ê¹ÓÃÕâЩ¹¤¾ß£¬¿ÉÒÔ×ÊÖúÖÎÀíÔ±¸üºÃµØÏàʶϵͳÔËÐÐÇéÐΣ¬²¢¿ìËÙ²éÕÒϵͳ¹ÊÕÏ¡£

ÒÔÉϾÍÊÇÔõÑù¾ÙÐÐLinuxϵͳµÄÈÕÖ¾ÍøÂçºÍÆÊÎöµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

QR code
sitemap¡¢ÍøÕ¾µØͼ