Log segmentation and scrolling with logrotate

Source: Internet
Author: User

Services on Linux server generally last long, so that the log files of services become larger over time, and if the log is poorly handled, it may even fill the disk. Fortunately found the Logrotate this program to deal with.

Here is the installation configuration process

zypper in -y logrotate# Although Logrotate is run by cron cat /etc/cron.daily/logrotate#!/bin/sh/usr/ sbin/logrotate /etc/logrotate.confexitvalue=$?if [  $EXITVALUE  != 0 ]; then     /usr/bin/logger -t logrotate  "alert exited abnormally  with [$EXITVALUE] "fiexit 0# and logrotate.conf will refer to/ETC/LOGROTATE.D directory cat /etc/logrotate.conf ... INCLUDE /ETC/LOGROTATE.D. Create a new configuration file to handle Nginx log files #在 the/ETC/LOGROTATE.D directory vim /etc/logrotate.d/nginx/opt/ nginx/logs/*.log {    daily    dateext     compress    rotate 3    sharedscripts     Postrotate        if [ -f /opt/nginx/logs/nginx.pid  ]; then           kill -USR1  ' Cat  /opt/nginx/logs/nginx.pid ' &Nbsp;       fi    endscript} 

You can also perform manual execution directly

Logrotate-d-f/etc/logrotate.d/nginx


Log segmentation and scrolling with logrotate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.