Running cPanel on a server with various customer accounts under the /home directory.
Many customers' error_log files are exceeding a desired size (let's say 100MB) and I want to create a cron job to run daily to truncate any files over a certain size.
I know truncate can shrink files but it will extend files if they're smaller than the stipulated amount, so does my solution below (of first finding all files above the desired size and only shrinking those) make the most sense and will it work?
for i in $(find /home -type f -iname error_log -size +99M); do
truncate -s 100M $i
done