Linux log rollback

Source: Internet
Author: User

Add logrotate file to/etc/cron.daily


#!/bin/sh


/usr/sbin/logrotate/etc/logrotate.conf

Exitvalue=$?

if [$EXITVALUE! = 0]; Then

/usr/bin/logger-t logrotate "ALERT exited abnormally with [$EXITVALUE]"

Fi

Exit 0



Add a log profile to the/ETC/LOGROTATE.D to configure the delete log


/log/*.log {

Daily

Noolddir

Rotate 7

Missingok

Notifempty

Sharedscripts

Postrotate

/bin/kill-hup ' cat/var/run/syslogd.pid 2>/dev/null ' 2>/dev/null | | True

/bin/kill-hup ' cat/var/run/rsyslogd.pid 2>/dev/null ' 2>/dev/null | | True

Endscript

}


Force restart Rollback Service

#logrotate-vf/etc/logrotate.conf

Or

/usr/sbin/logrotate-vf/etc/logrotate.conf


CRONTAB-L//Display the contents of the user's crontab file

CRONTAB-E//Edit the contents of a user's crontab file

Crontab-r//delete user's crontab file


Create a new execution script in the root directory

Touch logrotate.sh


#! /bash/sh

Su-root-c "Logrotate-vf/etc/logrotate.conf"


chmod u+x logrotate.sh

New timed Start

#crontab-E


5 7,19 * * * sh/root/logrotate.sh >> logrotate.log 2>&1



Restart Timer service

Service Crond Restart


Restart Log service

Service Syslog Restart

Force a rollback

Logrotate-vf/etc/logrotate.conf


This article is from the "Light Sigh Heart" blog, please be sure to keep this source http://dantanmingxin.blog.51cto.com/2061202/1827823

Linux log rollback

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.