Hostxpeed
Login Get Started →
Server Management

How to Rotate Logs Daily

3 min read
24 views
Jun 12, 2026

Prerequisites

Before rotating logs, make sure you have:

  • SSH access to your VPS
  • Root or sudo privileges

Step 1: Edit Global logrotate Configuration

Connect to your VPS:

ssh hxroot@YOUR_SERVER_IP -p 22
sudo nano /etc/logrotate.conf

Change:

# weekly
daily

Also adjust rotate count:

rotate 14   # Keep 14 days of daily logs

Step 2: Override for Specific Logs

Create or edit application-specific config:

sudo nano /etc/logrotate.d/nginx
/var/log/nginx/*.log {
    daily
    rotate 7
    compress
    delaycompress
    missingok
    notifempty
    create 640 www-data adm
    sharedscripts
    postrotate
        [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
    endscript
}

Step 3: Test Configuration

sudo logrotate -d /etc/logrotate.conf

Step 4: Force Rotation to Test

sudo logrotate -f /etc/logrotate.conf

Step 5: Verify Daily Rotation

ls -la /var/log/nginx/

You should see rotated files with dates.

✅ Log rotation set to daily. Logs will rotate every 24 hours.

Was this article helpful?