linux_wiki:log_rotate

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

linux_wiki:log_rotate [2015/10/04 01:19]
billdozor created
linux_wiki:log_rotate [2019/05/25 23:50]
Line 1: Line 1:
-====== Log Rotate ====== 
- 
-**General Information** 
- 
-  * The package "logrotate" is installed by default on most linux distros. 
-  * Logrotate is executed via a daily cron job: /etc/cron.daily/logrotate 
- 
-**Checklist** 
-  * Distro: Enterprise Linux 6 
- 
----- 
- 
-===== Force Rotation ===== 
- 
-Forcing a log rotation can be useful after implementing a new rotation file (in /etc/logrotate.d) or to test after making changes. 
- 
-  * To force a logrotate using a specific config file 
-    * <code bash>/usr/sbin/logrotate -f /etc/logrotate.d/myapp</code> 
-  * To force a logrotate of ALL log files 
-    * <code bash>/usr/sbin/logrotate -f /etc/logrotate.conf</code> 
- 
----- 
- 
-===== /etc/logrotate.conf ===== 
- 
-/etc/logrotate.conf is left alone in its default installed state. 
- 
-Ensure that /etc/logrotate.d is included (it is by default): 
-<code bash> 
-include /etc/logrotate.d 
-</code> 
- 
----- 
- 
-===== /etc/logrotate.d/ ===== 
- 
-All additional log configuration files go in: /etc/logrotate.d/ 
- 
-Example Log Config 
-<code bash> 
-## Application Logs ## 
-/opt/myapp/logs/logs.txt { 
-  #Rotate monthly 
-  monthly 
-   
-  #Keep 12 old log files, delete older 
-  rotate 12 
-   
-  #Copy current log to rotated, then truncate in place 
-  copytruncate 
-   
-  #Give rotated log file a date extension YYYYMMDD 
-  dateext 
-   
-  #Compress old log files with gzip 
-  compress 
-} 
-</code> 
- 
----- 
  
  • linux_wiki/log_rotate.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)