Short of using logrotate, below is a quick and simple script to do the same.
Example of haproxy log rotation
#!/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
Include this /etc/crontab
00 00 * * * root /var/log/logroll