Log Rotate: Difference between revisions

From DISI
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 3: Line 3:


== Installation ==
== Installation ==
 
yum update && yum install logrotate


== Configuration ==
== Configuration ==
# Edit the httpd log rotate conf file.
#*<code>vim /etc/logrotate.d/httpd</code>
# Delete all default lines and replace with these lines
<pre>/var/log/httpd/*log {
        monthly
        rotate 3
        size=10M
        compress
        missingok
        notifempty
dateext
dateformat -%m%d%Y
sharedscripts
postrotate
/root/scp_logs.sh
        /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
endscript
}


/var/log/httpd/*/*log {
        monthly
rotate 3
size=10M
compress
missingok
notifempty
dateext
        dateformat -%m%d%Y
sharedscripts
postrotate
/root/scp_logs.sh
/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
    endscript
}
</pre>
== Rsync Script ==
== Rsync Script ==

Revision as of 00:01, 19 March 2022

Introduction

Log Rotation is an automated process used in system administration in which log files are compressed, moved, renamed or deleted once they are too old or too big. New incoming log data is directed into a new fresh file.

Installation

yum update && yum install logrotate

Configuration

  1. Edit the httpd log rotate conf file.
    • vim /etc/logrotate.d/httpd
  2. Delete all default lines and replace with these lines
/var/log/httpd/*log {
        monthly
        rotate 3
        size=10M
        compress
        missingok
        notifempty
	dateext
	dateformat -%m%d%Y
	sharedscripts
	postrotate
		/root/scp_logs.sh
        	/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
	endscript
}

/var/log/httpd/*/*log {
        monthly
	rotate 3
	size=10M
	compress
	missingok
	notifempty
	dateext
        dateformat -%m%d%Y
	sharedscripts
	postrotate
		/root/scp_logs.sh
		/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
    	endscript
}

Rsync Script