logrotate

Log Rotate

Simple: Create following file Change the MAXSIZE & LOGDIR (see file) Add a cron job Create following file: nano /var/www/log/logrotate.sh #!/bin/bash MAXSIZE=1024 LOGDIR=/var/www/log/ if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi cd $LOGDIR for FILENAME in *.log; do SIZE=$(du -b $FILENAME | cut -f 1) if(($SIZE>$MAXSIZE)); then TIMESTAMP=`date +%Y%m%d` NEWFILENAME=$FILENAME.$TIMESTAMP mv $FILENAME $NEWFILENAME touch $FILENAME chown www-data.