Special Offers: Up to 75% OFF on Hostinger & High-RAM Contabo Cloud VPS available this month.Compare Plans

How to Configure Logrotate on Linux VPS to Prevent Nginx and Docker Logs from Filling Your Disk

Marcus Sterling
Marcus SterlingLinux Systems Engineer
October 26, 2026
•
14 min read
•
4.8 / 5.0
Transparency Notice: This article contains affiliate links to hosting providers like Hostinger and Contabo. If you purchase through our links, we may earn a commission at zero extra cost to you. We only recommend products we personally benchmark and test. Read full disclosure.
How to Configure Logrotate on Linux VPS to Prevent Nginx and Docker Logs from Filling Your Disk

Hostinger vs. Contabo: Full Specifications Breakdown

Data verified from our lab benchmarks • Updated for 2026

Feature / Metric
HostingerEditor's Choice UI
ContaboMax RAM Value
Starting Price$2.99 / month (Web) | $4.99 / mo (VPS)$5.50 / month (Cloud VPS S)
vCPU Cores1 to 8 vCPU (Dedicated resources)4 to 12 vCPU (High Core Count)
RAM Memory4 GB to 32 GB6 GB to 64 GB (Gigantic RAM)
Storage Technology50 GB – 400 GB NVMe SSD50 GB NVMe or 300 GB SSD
Traffic / Bandwidth4 TB to 32 TB32 TB Outgoing + Unlimited In
Control Panel & UIhPanel (Ultra Modern & Easy)cPanel, Plesk, Webmin, or CLI
Customer Support24/7 Live Chat & AI Support (Multi-lingual)Email Ticket Support (German Business Hours)
Best ForBloggers, WordPress Sites & Devs wanting easy UIHeavy Database, Docker, Game Servers & SysAdmins
Money-Back Guarantee30-Day Money-Back Guarantee14-Day EU Statutory Cancellation
Official LinksVisit HostingerVisit Contabo

The Silent Killer: Unchecked Log Growth

One of the most frequent causes of sudden production server failure is 100% disk saturation. On busy websites, Nginx access logs, Docker container outputs, and MySQL query logs write thousands of entries every minute. When a storage volume fills up completely, databases cannot write transaction logs, causing services to crash abruptly. Logrotate is the standard Linux utility designed to rotate, compress, and prune log archives automatically.

Creating a Production Nginx Logrotate Rule

sudo nano /etc/logrotate.d/nginx
/var/log/nginx/*.log {
    daily
    missingok
    rotate 14
    compress
    delaycompress
    notifempty
    create 0640 www-data adm
    sharedscripts
    prerotate
        if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
            run-parts /etc/logrotate.d/httpd-prerotate; \
        fi \
    endscript
    postrotate
        invoke-rc.d nginx rotate >/dev/null 2>&1
    endscript
}

Test the configuration with a dry run: sudo logrotate -d /etc/logrotate.d/nginx. Your logs are now automatically compressed and pruned after 14 days.

Editorial Verdict: Pros & Cons

What We Love (Pros)

  • Prevents catastrophic server downtime caused by unchecked gigabyte-sized log files
  • Compresses historical logs with gzip, cutting storage consumption by 90%
  • Executes automatically via background cron with zero manual intervention

Drawbacks (Cons)

  • Misconfigured log rotation permissions can prevent daemons from reopening log file handles
#Logrotate#Linux Administration#Server Maintenance#Disk Optimization#Ubuntu
Marcus Sterling

Written by Marcus Sterling

Linux Systems Engineer

Alex and the ServerCraft engineering lab run routine benchmarks on over 25 web hosting providers, maintaining strict objectivity and reproducibility.

Recommended Next Reads