Plesk: Finding large log files

I get this kind of problem every day: “We’ve run out of disc space on our Plesk server – what’s taking up all the space?” The answer, almost every time, is “logs.” Plesk doesn’t enable log rotation by default, so logs can end up taking a lot of space.

Here’s something I cooked up to list the size of each domain’s log directory:

# for logdir in $(find /var/www/vhosts/*/statistics/logs -type f); do \
echo $logdir; done | tr "\n" " " | xargs du -cl | sort -n

This will spit out something like:

704       /var/www/vhosts/foo.net/statistics/logs
3788      /var/www/vhosts/bar.net/statistics/logs
16        /var/www/vhosts/example.com/statistics/logs
52        /var/www/vhosts/joe.blogg.net/statistics/logs
950272    /var/www/vhosts/johndoe.com/statistics/logs
4812      /var/www/vhosts/randomstuff.org/statistics/logs
145408    /var/www/vhosts/sub.example.com/statistics/logs
1153433   total

If this doesn’t reveal anything noteworthy, you can drop the “| grep logs” to give you all directories under /var/www/vhosts/*/statistics.

Leave a Reply

Your email address will not be published. Required fields are marked *