Updated: 28 September 2026 · Applies to: Magento Open Source 2.4

Magento 2 writes logs to var/log/ in its folder. Without clean-up they grow until the disk is full. A daily cron job can archive and remove old logs.

Keep 14 days of logs

Add a cron job (cPanel: Advanced › Cron Jobs) that runs once a day:

find /home/USER/magento/var/log -name "*.log*" -type f -mtime +14 -delete

Keep a compressed copy before emptying a log

cd /home/USER/magento/var/log && gzip -c system.log > archive-system-$(date +%F).log.gz && : > system.log

Replace /home/USER/magento with your Magento folder. On a VPS, you can use logrotate instead.

Related services

Web hosting

shared hosting on Virtualmin with NVMe storage, free SSL and email.

Managed cPanel VPS

cPanel included; we handle updates, security and monitoring.

Hire an expert

engineers per 15 minutes, per hour or per month, with no contract.

Was this answer helpful?

Still stuck? Open a ticket