SlideShare uma empresa Scribd logo
1 de 11
Baixar para ler offline
How To Install and Configure Log Rotation on RHEL 7
i | P a g e
Table of Contents
Overview.......................................................................................................................................................1
Applies To......................................................................................................................................................1
Pre-Requisites ...............................................................................................................................................1
Check Package...........................................................................................................................................1
Install Package...........................................................................................................................................1
Verify Package...........................................................................................................................................2
Configuration Files / Location...................................................................................................................2
Logrotate – Configuration File ..............................................................................................................2
Logrotate – Configuration Directory to Include....................................................................................3
Logrotate – httpd Script............................................................................................................................3
Httpd – Rotation Script .........................................................................................................................3
logrotate – Run Status ..............................................................................................................................4
logrotate Manually....................................................................................................................................5
logrotate Manually - Verbose ...................................................................................................................5
logrotate Manually – Debug .....................................................................................................................5
logrotate Manually – All Configs...............................................................................................................6
logrotate – Custom Application Log .........................................................................................................6
Tomcat – Rotation Script – One Log File...............................................................................................6
logrotate – Custom Application Multiple Filters.......................................................................................7
Tomcat – Rotation Script – Multiple Filters ..........................................................................................7
Configurable Options....................................................................................................................................8
Shell Script - MoveOldLogs.sh...................................................................................................................9
PostRotate - Option ................................................................................................................................10
How To Install and Configure Log Rotation on RHEL 7
1 | P a g e
Overview
All the services or applications deployed on the system, generates event log’s in a file for each action that
is performed on the system / application / user. Over a period of time it becomes a tedious task to manage
such log files and grows in humongous sizes and the application performance would deteriorate
periodically.
To mitigate such issues and maintain log files we utilize “logrotate” which is designed to ease
administration. It takes care of automatic log file rotation, compression, removal and mailing of log files.
It can be configured to maintain logs file on daily, weekly monthly or when the size of the file is grown to
a specific size.
Ideally, logrotate is run as a cron job. To test or run manually you can run command “logrotate” with “-f”
parameter along with the configuration file.
Applies To
Tested on RHEL 7, CentOS 7, though it can be configured on most of the *nix flavor of OS.
Pre-Requisites
 logrotate
Check Package
Install the logrotate package, run the command
rpm -qa | grep logrotate
Install Package
Install the logrotate package, run the command;
yum install logrotate -y
How To Install and Configure Log Rotation on RHEL 7
2 | P a g e
Verify Package
To verify the logrotate package is installed, run the command;
rpm -qa | grep logrotate
Configuration Files / Location
By default, when the logrotate is installed. All the Configuration files “/etc/logrotate.conf” that are
configured.
/etc/logrotate.conf Default configuration file
/etc/logrotate.d/ Default directory for different service or application configuration file location
Logrotate – Configuration File
Default configuration file is configured as below. To display current configuration without comments, run
command;
grep -v "#" /etc/logrotate.conf
weekly
rotate 4
create
dateext
include /etc/logrotate.d
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
How To Install and Configure Log Rotation on RHEL 7
3 | P a g e
Logrotate – Configuration Directory to Include
The directive “include /etc/logrotate.d” that is configured, instructs the service to include the
configuration files in the directory “/etc/logrotate.d”.
cd /etc/logrotate.d/
ls -l
Logrotate – httpd Script
A sample script, which show as to how to configure log rotation for “/var/log/httpd/” location for all
“*.log” which is filtered files.
Httpd – Rotation Script
/var/log/httpd/*log {
missingok
notifempty
sharedscripts
delaycompress
postrotate
/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
endscript
}
How To Install and Configure Log Rotation on RHEL 7
4 | P a g e
logrotate – Run Status
To validate the logrotate run status for each configuration file and know the status of each one of them,
run the command; It will list run time for each config file.
cat /var/lib/logrotate.status
How To Install and Configure Log Rotation on RHEL 7
5 | P a g e
logrotate Manually
To run manually logrotate run the command below for specific configuration file.
logrotate -f /etc/logrotate.d/tomcat
logrotate Manually - Verbose
To verbose logrotate run the command below;
logrotate -v -f /etc/logrotate.d/tomcat
logrotate Manually – Debug
To debug logrotate and redirect the logs to a file, run the command below;
logrotate -d /etc/logrotate.conf 2> /tmp/logrotate.debug
How To Install and Configure Log Rotation on RHEL 7
6 | P a g e
logrotate Manually – All Configs
To rotate all the logs and in verbose mode, run the command below;
logrotate -f -v /etc/logrotate.conf
logrotate – Custom Application Log
To configure logrotate for a custom application. Create a new config file and configure the options for log
rotation in the folder “/etc/logrotate.d/”. We will be rotating a specific file “catalina.out” only. Set
options for the log rotation accordingly.
vi /etc/logrotate.d/tomcat
Tomcat – Rotation Script – One Log File
/usr/local/apache-tomcat-6.0.20/logs/catalina.out {
copytruncate
daily
dateext
rotate 30
size 100M
notifempty
missingok
compress
postrotate
/usr/bin/MoveOldLogs.sh || true
endscript
}
How To Install and Configure Log Rotation on RHEL 7
7 | P a g e
logrotate – Custom Application Multiple Filters
To configure logrotate for a custom application. Create a new configuration file and configure the options
for log rotation in the folder “/etc/logrotate.d/”.
We will be rotating a specific file “catalina.out” only. Another path wherein we will configure to rotate
filter files “*.log” for the paths. Similarly we can configure for different paths.
File Type #1 /usr/local/apache-tomcat-6.0.20/logs/catalina.out
File Type #2 /usr/local/apache-tomcat-6.0.20/logs/*.log
logrotate -v -f /etc/logrotate.d/tomcat
Tomcat – Rotation Script – Multiple Filters
/usr/local/apache-tomcat-6.0.20/logs/catalina.out /usr/local/apache-tomcat-6.0.20/logs/*.log {
copytruncate
daily
dateext
rotate 30
size 100M
notifempty
missingok
compress
postrotate
/usr/bin/MoveOldLogs.sh || true
endscript
}
How To Install and Configure Log Rotation on RHEL 7
8 | P a g e
Configurable Options
A lot of other configurable options and with its function.
Options Function
compress To compress the rotated log file with gzip
nocompress Compression is disabled
copytruncate When processes are still writing information to open log files. It will copy the
active log file to a backup file and truncates the active log file
nocopytruncate Will copy the log files to backup file, but the open log file will not be
truncated
create mode owner
group
rotates the log file and creates a new log file with the specified permissions,
owner, and group.
The default is to use the same mode, owner, and group as the original file
nocreate prevents the creation of a new log file creation
delaycompress It’s used with the compress option is set, then rotated log file is not
compressed until the next time it is cycled
nodelaycompress overrides delaycompress. The log file is compressed when it is cycled
errors address If logrotate encounters errors to an email address
ifempty Log file is rotated even if it is empty. It’s the default setting
notifempty Does not rotate the log file, if it is empty file or zero byte file
mail address This mails log files that are cycled to an address. When mail log files are
cycled, they are effectively removed from the system
nomail When mail log files are cycled, a copy is not mailed
olddir directory With this, cycled log files are kept in the specified directory. This directory
must be on the same filesystem as the current log files
How To Install and Configure Log Rotation on RHEL 7
9 | P a g e
noolddir Cycled log files are kept in the same directory as the current log files
prerotate/endscript Before rotation run. The prerotate and endscript invoke task or script, check
script below.
postrotate/endscript After rotation run. The postrotate and endscript invoke task or script, check
script below.
daily To rotate log files daily
weekly To rotate log files weekly
monthly To rotate log files monthly
rotate count Specifies the number of times to rotate a file before it is deleted. 0 (zero)
means no copies are retained. In case you set it as 7, seven copies are
retained.
tabootext [+] list directs logrotate to not rotate files with the specified extension. The default
list of extensions is .rpm-orig, .rpmsave, v, and ~.
size size With this, the log file is rotated when the specified size is reached. Size may
be specified in bytes (default), kilobytes (sizek), or megabytes (sizem).
Shell Script - MoveOldLogs.sh
#!/bin/bash
LogPath=/usr/local/apache-tomcat-6.0.20/logs/
LogFileName=catalina.out
LogDate=$(date +"%m%d%Y")
MoveFileName=${LogPath}${LogFileName}
DestPath=/var/log/archive-logs/apache-tomcat/
#
# Create Destination path if it doesn't exists
#
if [ ! -d ${DestPath} ]; then
mkdir -p ${DestPath}
fi
#
# Move the file to a archive folder
#
mv ${MoveFileName} ${DestPath}${LogFileName}.${LogDate}
gzip ${DestPath}/${LogFileName}.${LogDate}
exit
How To Install and Configure Log Rotation on RHEL 7
10 | P a g e
PostRotate - Option
Invoke command / task between postrotate and endscript tags.
postrotate
/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
endscript

Mais conteúdo relacionado

Mais procurados

Yocto: Training in English
Yocto: Training in EnglishYocto: Training in English
Yocto: Training in EnglishOtavio Salvador
 
Memory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelMemory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelAdrian Huang
 
Page Cache in Linux 2.6.pdf
Page Cache in Linux 2.6.pdfPage Cache in Linux 2.6.pdf
Page Cache in Linux 2.6.pdfycelgemici1
 
The internals and the latest trends of container runtimes
The internals and the latest trends of container runtimesThe internals and the latest trends of container runtimes
The internals and the latest trends of container runtimesAkihiro Suda
 
[KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...
 [KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui... [KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...
[KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...Akihiro Suda
 
Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)RajKumar Rampelli
 
Troubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversTroubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversSatpal Parmar
 
High Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniHigh Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniZalando Technology
 
IRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the PreemptibleIRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the PreemptibleAlison Chaiken
 
[2021] kotlin - inheritance
[2021] kotlin - inheritance[2021] kotlin - inheritance
[2021] kotlin - inheritanceWei-Shen Lu
 
BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)Brendan Gregg
 
Ext4 write barrier
Ext4 write barrierExt4 write barrier
Ext4 write barrierSomdutta Roy
 
Fun with Network Interfaces
Fun with Network InterfacesFun with Network Interfaces
Fun with Network InterfacesKernel TLV
 
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedKernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedAnne Nicolas
 
twlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsotwlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsoViller Hsiao
 
Introduction to Return-Oriented Exploitation on ARM64 - Billy Ellis
Introduction to Return-Oriented Exploitation on ARM64 - Billy EllisIntroduction to Return-Oriented Exploitation on ARM64 - Billy Ellis
Introduction to Return-Oriented Exploitation on ARM64 - Billy EllisBillyEllis3
 

Mais procurados (20)

spinlock.pdf
spinlock.pdfspinlock.pdf
spinlock.pdf
 
Yocto: Training in English
Yocto: Training in EnglishYocto: Training in English
Yocto: Training in English
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Memory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelMemory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux Kernel
 
Basics of-linux
Basics of-linuxBasics of-linux
Basics of-linux
 
Page Cache in Linux 2.6.pdf
Page Cache in Linux 2.6.pdfPage Cache in Linux 2.6.pdf
Page Cache in Linux 2.6.pdf
 
The internals and the latest trends of container runtimes
The internals and the latest trends of container runtimesThe internals and the latest trends of container runtimes
The internals and the latest trends of container runtimes
 
[KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...
 [KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui... [KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...
[KubeConUS2019 Docker, Inc. Booth] Distributed Builds on Kubernetes with Bui...
 
Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)Tasklet vs work queues (Deferrable functions in linux)
Tasklet vs work queues (Deferrable functions in linux)
 
Troubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device DriversTroubleshooting Linux Kernel Modules And Device Drivers
Troubleshooting Linux Kernel Modules And Device Drivers
 
High Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniHigh Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando Patroni
 
IRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the PreemptibleIRQs: the Hard, the Soft, the Threaded and the Preemptible
IRQs: the Hard, the Soft, the Threaded and the Preemptible
 
[2021] kotlin - inheritance
[2021] kotlin - inheritance[2021] kotlin - inheritance
[2021] kotlin - inheritance
 
BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)
 
Ext4 write barrier
Ext4 write barrierExt4 write barrier
Ext4 write barrier
 
U boot-boot-flow
U boot-boot-flowU boot-boot-flow
U boot-boot-flow
 
Fun with Network Interfaces
Fun with Network InterfacesFun with Network Interfaces
Fun with Network Interfaces
 
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedKernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
 
twlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdsotwlkh-linux-vsyscall-and-vdso
twlkh-linux-vsyscall-and-vdso
 
Introduction to Return-Oriented Exploitation on ARM64 - Billy Ellis
Introduction to Return-Oriented Exploitation on ARM64 - Billy EllisIntroduction to Return-Oriented Exploitation on ARM64 - Billy Ellis
Introduction to Return-Oriented Exploitation on ARM64 - Billy Ellis
 

Destaque

How To Install and Configure Screen on CentOS 7
How To Install and Configure Screen on CentOS 7How To Install and Configure Screen on CentOS 7
How To Install and Configure Screen on CentOS 7VCP Muthukrishna
 
How To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShellHow To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShellVCP Muthukrishna
 
How To Disable IE Enhanced Security Windows PowerShell
How To Disable IE Enhanced Security Windows PowerShellHow To Disable IE Enhanced Security Windows PowerShell
How To Disable IE Enhanced Security Windows PowerShellVCP Muthukrishna
 
Nginx bind() to 0.0.0.0:9080 failed
Nginx bind() to 0.0.0.0:9080 failedNginx bind() to 0.0.0.0:9080 failed
Nginx bind() to 0.0.0.0:9080 failedVCP Muthukrishna
 
How To Install and Configure Salt Master on Ubuntu
How To Install and Configure Salt Master on UbuntuHow To Install and Configure Salt Master on Ubuntu
How To Install and Configure Salt Master on UbuntuVCP Muthukrishna
 
How To Configure SNMP Logging on RHEL 7
How To Configure SNMP Logging on RHEL 7How To Configure SNMP Logging on RHEL 7
How To Configure SNMP Logging on RHEL 7VCP Muthukrishna
 
How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7VCP Muthukrishna
 
How To Protect SSH Access with Fail2Ban on RHEL 7
How To Protect SSH Access with Fail2Ban on RHEL 7How To Protect SSH Access with Fail2Ban on RHEL 7
How To Protect SSH Access with Fail2Ban on RHEL 7VCP Muthukrishna
 

Destaque (8)

How To Install and Configure Screen on CentOS 7
How To Install and Configure Screen on CentOS 7How To Install and Configure Screen on CentOS 7
How To Install and Configure Screen on CentOS 7
 
How To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShellHow To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShell
 
How To Disable IE Enhanced Security Windows PowerShell
How To Disable IE Enhanced Security Windows PowerShellHow To Disable IE Enhanced Security Windows PowerShell
How To Disable IE Enhanced Security Windows PowerShell
 
Nginx bind() to 0.0.0.0:9080 failed
Nginx bind() to 0.0.0.0:9080 failedNginx bind() to 0.0.0.0:9080 failed
Nginx bind() to 0.0.0.0:9080 failed
 
How To Install and Configure Salt Master on Ubuntu
How To Install and Configure Salt Master on UbuntuHow To Install and Configure Salt Master on Ubuntu
How To Install and Configure Salt Master on Ubuntu
 
How To Configure SNMP Logging on RHEL 7
How To Configure SNMP Logging on RHEL 7How To Configure SNMP Logging on RHEL 7
How To Configure SNMP Logging on RHEL 7
 
How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7
 
How To Protect SSH Access with Fail2Ban on RHEL 7
How To Protect SSH Access with Fail2Ban on RHEL 7How To Protect SSH Access with Fail2Ban on RHEL 7
How To Protect SSH Access with Fail2Ban on RHEL 7
 

Semelhante a How To Install and Configure Log Rotation on RHEL 7 or CentOS 7

How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7VCP Muthukrishna
 
How To Reset root Password on CentOS 7
How To Reset root Password on CentOS 7How To Reset root Password on CentOS 7
How To Reset root Password on CentOS 7VCP Muthukrishna
 
Install elasticsearch, logstash and kibana
Install elasticsearch, logstash and kibana Install elasticsearch, logstash and kibana
Install elasticsearch, logstash and kibana Chanaka Lasantha
 
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in UbuntuHow To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in UbuntuWirabumi Software
 
How to Configure OpenFiler for NFS Share
How to Configure OpenFiler for NFS ShareHow to Configure OpenFiler for NFS Share
How to Configure OpenFiler for NFS ShareVCP Muthukrishna
 
How To Install and Generate Audit Reports in CentOS 7 or RHEL 7
How To Install and Generate Audit Reports in CentOS 7 or RHEL 7How To Install and Generate Audit Reports in CentOS 7 or RHEL 7
How To Install and Generate Audit Reports in CentOS 7 or RHEL 7VCP Muthukrishna
 
How to Upgrade Openfire on CentOS 7
How to Upgrade Openfire on CentOS 7How to Upgrade Openfire on CentOS 7
How to Upgrade Openfire on CentOS 7VCP Muthukrishna
 
Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7VCP Muthukrishna
 
L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5William Lee
 
Snort296x centos6x 2
Snort296x centos6x 2Snort296x centos6x 2
Snort296x centos6x 2Trinh Tuan
 
How tos nagios - centos wiki
How tos nagios - centos wikiHow tos nagios - centos wiki
How tos nagios - centos wikishahab071
 
Inspection and maintenance tools (Linux / OpenStack)
Inspection and maintenance tools (Linux / OpenStack)Inspection and maintenance tools (Linux / OpenStack)
Inspection and maintenance tools (Linux / OpenStack)Gerard Braad
 
Bundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMBundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMAlexander Shopov
 
How To Configure Apache VirtualHost on RHEL 7 on AWS
How To Configure Apache VirtualHost on RHEL 7 on AWSHow To Configure Apache VirtualHost on RHEL 7 on AWS
How To Configure Apache VirtualHost on RHEL 7 on AWSVCP Muthukrishna
 
2.5 use rpm and yum package management
2.5 use rpm and yum package management2.5 use rpm and yum package management
2.5 use rpm and yum package managementAcácio Oliveira
 
Install nagios
Install nagiosInstall nagios
Install nagioshassandb
 
Install nagios
Install nagiosInstall nagios
Install nagioshassandb
 
Install nagios
Install nagiosInstall nagios
Install nagioshassandb
 

Semelhante a How To Install and Configure Log Rotation on RHEL 7 or CentOS 7 (20)

How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7
 
How To Reset root Password on CentOS 7
How To Reset root Password on CentOS 7How To Reset root Password on CentOS 7
How To Reset root Password on CentOS 7
 
Install elasticsearch, logstash and kibana
Install elasticsearch, logstash and kibana Install elasticsearch, logstash and kibana
Install elasticsearch, logstash and kibana
 
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in UbuntuHow To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
 
How to Configure OpenFiler for NFS Share
How to Configure OpenFiler for NFS ShareHow to Configure OpenFiler for NFS Share
How to Configure OpenFiler for NFS Share
 
How To Install and Generate Audit Reports in CentOS 7 or RHEL 7
How To Install and Generate Audit Reports in CentOS 7 or RHEL 7How To Install and Generate Audit Reports in CentOS 7 or RHEL 7
How To Install and Generate Audit Reports in CentOS 7 or RHEL 7
 
How to Upgrade Openfire on CentOS 7
How to Upgrade Openfire on CentOS 7How to Upgrade Openfire on CentOS 7
How to Upgrade Openfire on CentOS 7
 
Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7
 
L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5
 
Snort296x centos6x 2
Snort296x centos6x 2Snort296x centos6x 2
Snort296x centos6x 2
 
How tos nagios - centos wiki
How tos nagios - centos wikiHow tos nagios - centos wiki
How tos nagios - centos wiki
 
Inspection and maintenance tools (Linux / OpenStack)
Inspection and maintenance tools (Linux / OpenStack)Inspection and maintenance tools (Linux / OpenStack)
Inspection and maintenance tools (Linux / OpenStack)
 
Bundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMBundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPM
 
How To Configure Apache VirtualHost on RHEL 7 on AWS
How To Configure Apache VirtualHost on RHEL 7 on AWSHow To Configure Apache VirtualHost on RHEL 7 on AWS
How To Configure Apache VirtualHost on RHEL 7 on AWS
 
2.5 use rpm and yum package management
2.5 use rpm and yum package management2.5 use rpm and yum package management
2.5 use rpm and yum package management
 
Install nagios
Install nagiosInstall nagios
Install nagios
 
Install nagios
Install nagiosInstall nagios
Install nagios
 
Install nagios
Install nagiosInstall nagios
Install nagios
 
The Domino 10 RHEL 7 Primer
The Domino 10 RHEL 7 PrimerThe Domino 10 RHEL 7 Primer
The Domino 10 RHEL 7 Primer
 
Snort-IPS-Tutorial
Snort-IPS-TutorialSnort-IPS-Tutorial
Snort-IPS-Tutorial
 

Mais de VCP Muthukrishna

How to Fix Duplicate Packages in YUM on CentOS 7
How to Fix Duplicate Packages in YUM on CentOS 7How to Fix Duplicate Packages in YUM on CentOS 7
How to Fix Duplicate Packages in YUM on CentOS 7VCP Muthukrishna
 
How To Install and Configure GNome on CentOS 7
How To Install and Configure GNome on CentOS 7How To Install and Configure GNome on CentOS 7
How To Install and Configure GNome on CentOS 7VCP Muthukrishna
 
How To Connect to Active Directory User Validation
How To Connect to Active Directory User ValidationHow To Connect to Active Directory User Validation
How To Connect to Active Directory User ValidationVCP Muthukrishna
 
How To Connect To Active Directory PowerShell
How To Connect To Active Directory PowerShellHow To Connect To Active Directory PowerShell
How To Connect To Active Directory PowerShellVCP Muthukrishna
 
How To List Files on Remote Server - PowerShell
How To List Files on Remote Server - PowerShellHow To List Files on Remote Server - PowerShell
How To List Files on Remote Server - PowerShellVCP Muthukrishna
 
How To List Files and Display In HTML Format
How To List Files and Display In HTML FormatHow To List Files and Display In HTML Format
How To List Files and Display In HTML FormatVCP Muthukrishna
 
How To Check and Delete a File via PowerShell
How To Check and Delete a File via PowerShellHow To Check and Delete a File via PowerShell
How To Check and Delete a File via PowerShellVCP Muthukrishna
 
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...VCP Muthukrishna
 
How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7VCP Muthukrishna
 
How To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on UbuntuHow To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on UbuntuVCP Muthukrishna
 
Windows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive InfoWindows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive InfoVCP Muthukrishna
 
How To List Nginx Modules Installed / Complied on CentOS 7
How To List Nginx Modules Installed / Complied on CentOS 7How To List Nginx Modules Installed / Complied on CentOS 7
How To List Nginx Modules Installed / Complied on CentOS 7VCP Muthukrishna
 
Windows PowerShell Basics – How To Create powershell for loop
Windows PowerShell Basics – How To Create powershell for loopWindows PowerShell Basics – How To Create powershell for loop
Windows PowerShell Basics – How To Create powershell for loopVCP Muthukrishna
 
How To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional StatementsHow To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional StatementsVCP Muthukrishna
 
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional ParameterHow To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional ParameterVCP Muthukrishna
 
How To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter ValueHow To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter ValueVCP Muthukrishna
 
How To Create PowerShell Function
How To Create PowerShell FunctionHow To Create PowerShell Function
How To Create PowerShell FunctionVCP Muthukrishna
 
How To Find Package Installation Date on RHEL 7
How To Find Package Installation Date on RHEL 7How To Find Package Installation Date on RHEL 7
How To Find Package Installation Date on RHEL 7VCP Muthukrishna
 
How To View Current Execution Policy PowerShell
How To View Current Execution Policy PowerShellHow To View Current Execution Policy PowerShell
How To View Current Execution Policy PowerShellVCP Muthukrishna
 
How To Check file exists and Delete PowerShell
How To Check file exists and Delete PowerShellHow To Check file exists and Delete PowerShell
How To Check file exists and Delete PowerShellVCP Muthukrishna
 

Mais de VCP Muthukrishna (20)

How to Fix Duplicate Packages in YUM on CentOS 7
How to Fix Duplicate Packages in YUM on CentOS 7How to Fix Duplicate Packages in YUM on CentOS 7
How to Fix Duplicate Packages in YUM on CentOS 7
 
How To Install and Configure GNome on CentOS 7
How To Install and Configure GNome on CentOS 7How To Install and Configure GNome on CentOS 7
How To Install and Configure GNome on CentOS 7
 
How To Connect to Active Directory User Validation
How To Connect to Active Directory User ValidationHow To Connect to Active Directory User Validation
How To Connect to Active Directory User Validation
 
How To Connect To Active Directory PowerShell
How To Connect To Active Directory PowerShellHow To Connect To Active Directory PowerShell
How To Connect To Active Directory PowerShell
 
How To List Files on Remote Server - PowerShell
How To List Files on Remote Server - PowerShellHow To List Files on Remote Server - PowerShell
How To List Files on Remote Server - PowerShell
 
How To List Files and Display In HTML Format
How To List Files and Display In HTML FormatHow To List Files and Display In HTML Format
How To List Files and Display In HTML Format
 
How To Check and Delete a File via PowerShell
How To Check and Delete a File via PowerShellHow To Check and Delete a File via PowerShell
How To Check and Delete a File via PowerShell
 
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
 
How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7
 
How To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on UbuntuHow To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on Ubuntu
 
Windows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive InfoWindows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive Info
 
How To List Nginx Modules Installed / Complied on CentOS 7
How To List Nginx Modules Installed / Complied on CentOS 7How To List Nginx Modules Installed / Complied on CentOS 7
How To List Nginx Modules Installed / Complied on CentOS 7
 
Windows PowerShell Basics – How To Create powershell for loop
Windows PowerShell Basics – How To Create powershell for loopWindows PowerShell Basics – How To Create powershell for loop
Windows PowerShell Basics – How To Create powershell for loop
 
How To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional StatementsHow To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional Statements
 
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional ParameterHow To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
 
How To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter ValueHow To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter Value
 
How To Create PowerShell Function
How To Create PowerShell FunctionHow To Create PowerShell Function
How To Create PowerShell Function
 
How To Find Package Installation Date on RHEL 7
How To Find Package Installation Date on RHEL 7How To Find Package Installation Date on RHEL 7
How To Find Package Installation Date on RHEL 7
 
How To View Current Execution Policy PowerShell
How To View Current Execution Policy PowerShellHow To View Current Execution Policy PowerShell
How To View Current Execution Policy PowerShell
 
How To Check file exists and Delete PowerShell
How To Check file exists and Delete PowerShellHow To Check file exists and Delete PowerShell
How To Check file exists and Delete PowerShell
 

Último

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 

How To Install and Configure Log Rotation on RHEL 7 or CentOS 7

  • 1. How To Install and Configure Log Rotation on RHEL 7 i | P a g e Table of Contents Overview.......................................................................................................................................................1 Applies To......................................................................................................................................................1 Pre-Requisites ...............................................................................................................................................1 Check Package...........................................................................................................................................1 Install Package...........................................................................................................................................1 Verify Package...........................................................................................................................................2 Configuration Files / Location...................................................................................................................2 Logrotate – Configuration File ..............................................................................................................2 Logrotate – Configuration Directory to Include....................................................................................3 Logrotate – httpd Script............................................................................................................................3 Httpd – Rotation Script .........................................................................................................................3 logrotate – Run Status ..............................................................................................................................4 logrotate Manually....................................................................................................................................5 logrotate Manually - Verbose ...................................................................................................................5 logrotate Manually – Debug .....................................................................................................................5 logrotate Manually – All Configs...............................................................................................................6 logrotate – Custom Application Log .........................................................................................................6 Tomcat – Rotation Script – One Log File...............................................................................................6 logrotate – Custom Application Multiple Filters.......................................................................................7 Tomcat – Rotation Script – Multiple Filters ..........................................................................................7 Configurable Options....................................................................................................................................8 Shell Script - MoveOldLogs.sh...................................................................................................................9 PostRotate - Option ................................................................................................................................10
  • 2. How To Install and Configure Log Rotation on RHEL 7 1 | P a g e Overview All the services or applications deployed on the system, generates event log’s in a file for each action that is performed on the system / application / user. Over a period of time it becomes a tedious task to manage such log files and grows in humongous sizes and the application performance would deteriorate periodically. To mitigate such issues and maintain log files we utilize “logrotate” which is designed to ease administration. It takes care of automatic log file rotation, compression, removal and mailing of log files. It can be configured to maintain logs file on daily, weekly monthly or when the size of the file is grown to a specific size. Ideally, logrotate is run as a cron job. To test or run manually you can run command “logrotate” with “-f” parameter along with the configuration file. Applies To Tested on RHEL 7, CentOS 7, though it can be configured on most of the *nix flavor of OS. Pre-Requisites  logrotate Check Package Install the logrotate package, run the command rpm -qa | grep logrotate Install Package Install the logrotate package, run the command; yum install logrotate -y
  • 3. How To Install and Configure Log Rotation on RHEL 7 2 | P a g e Verify Package To verify the logrotate package is installed, run the command; rpm -qa | grep logrotate Configuration Files / Location By default, when the logrotate is installed. All the Configuration files “/etc/logrotate.conf” that are configured. /etc/logrotate.conf Default configuration file /etc/logrotate.d/ Default directory for different service or application configuration file location Logrotate – Configuration File Default configuration file is configured as below. To display current configuration without comments, run command; grep -v "#" /etc/logrotate.conf weekly rotate 4 create dateext include /etc/logrotate.d /var/log/wtmp { monthly create 0664 root utmp minsize 1M rotate 1 } /var/log/btmp { missingok monthly create 0600 root utmp rotate 1 }
  • 4. How To Install and Configure Log Rotation on RHEL 7 3 | P a g e Logrotate – Configuration Directory to Include The directive “include /etc/logrotate.d” that is configured, instructs the service to include the configuration files in the directory “/etc/logrotate.d”. cd /etc/logrotate.d/ ls -l Logrotate – httpd Script A sample script, which show as to how to configure log rotation for “/var/log/httpd/” location for all “*.log” which is filtered files. Httpd – Rotation Script /var/log/httpd/*log { missingok notifempty sharedscripts delaycompress postrotate /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true endscript }
  • 5. How To Install and Configure Log Rotation on RHEL 7 4 | P a g e logrotate – Run Status To validate the logrotate run status for each configuration file and know the status of each one of them, run the command; It will list run time for each config file. cat /var/lib/logrotate.status
  • 6. How To Install and Configure Log Rotation on RHEL 7 5 | P a g e logrotate Manually To run manually logrotate run the command below for specific configuration file. logrotate -f /etc/logrotate.d/tomcat logrotate Manually - Verbose To verbose logrotate run the command below; logrotate -v -f /etc/logrotate.d/tomcat logrotate Manually – Debug To debug logrotate and redirect the logs to a file, run the command below; logrotate -d /etc/logrotate.conf 2> /tmp/logrotate.debug
  • 7. How To Install and Configure Log Rotation on RHEL 7 6 | P a g e logrotate Manually – All Configs To rotate all the logs and in verbose mode, run the command below; logrotate -f -v /etc/logrotate.conf logrotate – Custom Application Log To configure logrotate for a custom application. Create a new config file and configure the options for log rotation in the folder “/etc/logrotate.d/”. We will be rotating a specific file “catalina.out” only. Set options for the log rotation accordingly. vi /etc/logrotate.d/tomcat Tomcat – Rotation Script – One Log File /usr/local/apache-tomcat-6.0.20/logs/catalina.out { copytruncate daily dateext rotate 30 size 100M notifempty missingok compress postrotate /usr/bin/MoveOldLogs.sh || true endscript }
  • 8. How To Install and Configure Log Rotation on RHEL 7 7 | P a g e logrotate – Custom Application Multiple Filters To configure logrotate for a custom application. Create a new configuration file and configure the options for log rotation in the folder “/etc/logrotate.d/”. We will be rotating a specific file “catalina.out” only. Another path wherein we will configure to rotate filter files “*.log” for the paths. Similarly we can configure for different paths. File Type #1 /usr/local/apache-tomcat-6.0.20/logs/catalina.out File Type #2 /usr/local/apache-tomcat-6.0.20/logs/*.log logrotate -v -f /etc/logrotate.d/tomcat Tomcat – Rotation Script – Multiple Filters /usr/local/apache-tomcat-6.0.20/logs/catalina.out /usr/local/apache-tomcat-6.0.20/logs/*.log { copytruncate daily dateext rotate 30 size 100M notifempty missingok compress postrotate /usr/bin/MoveOldLogs.sh || true endscript }
  • 9. How To Install and Configure Log Rotation on RHEL 7 8 | P a g e Configurable Options A lot of other configurable options and with its function. Options Function compress To compress the rotated log file with gzip nocompress Compression is disabled copytruncate When processes are still writing information to open log files. It will copy the active log file to a backup file and truncates the active log file nocopytruncate Will copy the log files to backup file, but the open log file will not be truncated create mode owner group rotates the log file and creates a new log file with the specified permissions, owner, and group. The default is to use the same mode, owner, and group as the original file nocreate prevents the creation of a new log file creation delaycompress It’s used with the compress option is set, then rotated log file is not compressed until the next time it is cycled nodelaycompress overrides delaycompress. The log file is compressed when it is cycled errors address If logrotate encounters errors to an email address ifempty Log file is rotated even if it is empty. It’s the default setting notifempty Does not rotate the log file, if it is empty file or zero byte file mail address This mails log files that are cycled to an address. When mail log files are cycled, they are effectively removed from the system nomail When mail log files are cycled, a copy is not mailed olddir directory With this, cycled log files are kept in the specified directory. This directory must be on the same filesystem as the current log files
  • 10. How To Install and Configure Log Rotation on RHEL 7 9 | P a g e noolddir Cycled log files are kept in the same directory as the current log files prerotate/endscript Before rotation run. The prerotate and endscript invoke task or script, check script below. postrotate/endscript After rotation run. The postrotate and endscript invoke task or script, check script below. daily To rotate log files daily weekly To rotate log files weekly monthly To rotate log files monthly rotate count Specifies the number of times to rotate a file before it is deleted. 0 (zero) means no copies are retained. In case you set it as 7, seven copies are retained. tabootext [+] list directs logrotate to not rotate files with the specified extension. The default list of extensions is .rpm-orig, .rpmsave, v, and ~. size size With this, the log file is rotated when the specified size is reached. Size may be specified in bytes (default), kilobytes (sizek), or megabytes (sizem). Shell Script - MoveOldLogs.sh #!/bin/bash LogPath=/usr/local/apache-tomcat-6.0.20/logs/ LogFileName=catalina.out LogDate=$(date +"%m%d%Y") MoveFileName=${LogPath}${LogFileName} DestPath=/var/log/archive-logs/apache-tomcat/ # # Create Destination path if it doesn't exists # if [ ! -d ${DestPath} ]; then mkdir -p ${DestPath} fi # # Move the file to a archive folder # mv ${MoveFileName} ${DestPath}${LogFileName}.${LogDate} gzip ${DestPath}/${LogFileName}.${LogDate} exit
  • 11. How To Install and Configure Log Rotation on RHEL 7 10 | P a g e PostRotate - Option Invoke command / task between postrotate and endscript tags. postrotate /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true endscript