no way to compare when less than two revisions

Differences

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


tech:linux:rotate_logs [2015/08/03 11:46] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== Log Rotation script ======
 +Short of using logrotate, below is a quick and simple script to do the same.
 +
 +===== Script =====
 +Example of haproxy log rotation
 +<code bash>
 +#!/bin/bash
 +#
 +LOGDIR=/var/log
 +LOGFILE=haproxy.log
 +TARDIR=/data/log
 +#
 +LOGDIRFILE=${LOGDIR}/${LOGFILE}
 +cp $LOGDIRFILE ${TARDIR}/${LOGFILE}.`date +%Y%m%d_%H%M%S`
 +cat /dev/null > $LOGDIRFILE
 +exit
 +</code>
 +
 +===== crontab entry =====
 +Include this /etc/crontab
 +<code>
 +00 00 * * * root /var/log/logroll
 +</code>
  

QR Code
QR Code tech:linux:rotate_logs (generated for current page)