#!/bin/sh # timer to clean some big logs # empty file if size is more than 52 Kb MAX_SIZE=52 while [ 1 ]; do for file in $(find /var/log/ -type f); do size=$(du -a $file| awk '{print $1}') if [ $size -gt $MAX_SIZE ]; then logger "clear-logs $file have BIG size $size Kb, empty it" last_line=$(tail -1 $file) echo $last_line > $file fi done sleep 60 done