Stratus Guides - Rotating Magento Logs
Rotating logs can help prevent log files from becoming too large and unwieldy.
To setup Logrotate to automatically rotate Magento logs:
Create a directory outside of the webroot to hold the config files:
mkdir /srv/etc/ mkdir /srv/etc/logrotateCreate a
logrotate.conffile with the following content:/srv/public_html/var/log/*.log { su magemojo magemojo daily missingok rotate 30 compress delaycompress notifempty olddir /srv/scaled/var/log/old/ }- su magemojo magemojo — Ensures that permissions stay correct
- daily – Run once a day at time set by cron job
- missingok — Don’t panic if empty
- rotate 30 — Retain for 30 days
- compress — Compress 2nd most recent file
- delaycompress — Do not compress newest rotated log
- notifempty — Do not rotate empty files
Add a [cron job](/docs/reference/stratus/control-panels/cron-panel/schedule/ “Cron Schedule Control Panel”/) to run once a day at the correct time:
/usr/sbin/logrotate -s /srv/etc/logrotate/logrotate.state /srv/etc/logrotate/logrotate.conf
Have questions not answered here?
Contact Support
to get more help.
Last modified on June 3, 2026