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=/ | ||
+ | LOGFILE=haproxy.log | ||
+ | TARDIR=/ | ||
+ | # | ||
+ | LOGDIRFILE=${LOGDIR}/ | ||
+ | cp $LOGDIRFILE ${TARDIR}/ | ||
+ | cat /dev/null > $LOGDIRFILE | ||
+ | exit | ||
+ | </ | ||
+ | |||
+ | ===== crontab entry ===== | ||
+ | Include this / | ||
+ | < | ||
+ | 00 00 * * * root / | ||
+ | </ | ||