• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Apache Command: rotatelogs

December 17, 2023

Apache Command: rotatelogs

Apache is one of the most popular web servers in the world, known for its flexibility and robustness. It offers a wide range of features and commands that allow administrators to customize and optimize their server configurations. One such command is rotatelogs, which is used to rotate Apache log files.

What is rotatelogs?

Rotatelogs is a utility that comes bundled with Apache HTTP Server. It allows you to rotate log files based on various criteria, such as time, size, or a combination of both. By rotating log files, you can effectively manage disk space and ensure that log files don’t grow indefinitely.

How does rotatelogs work?

The basic syntax of the rotatelogs command is as follows:

rotatelogs [options] logfile rotationtime [offset]

Let’s break down the different components of this command:

  • options: This refers to any additional flags or parameters that you can pass to the rotatelogs command. Some common options include specifying the log file format, compressing rotated log files, or specifying a delay before the first rotation.
  • logfile: This is the path to the log file that you want to rotate. For example, /var/log/apache/access.log.
  • rotationtime: This specifies the rotation time interval. It can be specified in various formats, such as seconds, minutes, hours, or days. For example, 86400 represents 24 hours.
  • offset: This is an optional parameter that allows you to specify an offset from the local time. It can be useful if you want to rotate log files at a specific time of day, regardless of the server’s time zone.

Once you have configured the rotatelogs command, you can set it up as a log file handler in your Apache configuration file. This ensures that Apache automatically rotates the log file based on the specified criteria.

Example Usage

Let’s say you want to rotate the Apache access log file every day and compress the rotated log files. You can use the following command:

rotatelogs -f /var/log/apache/access.log.%Y%m%d 86400 | gzip > /var/log/apache/access.log.%Y%m%d.gz

In this example, the %Y%m%d format specifier is used to include the current date in the rotated log file name. The 86400 rotation time specifies that the log file should be rotated every 24 hours.

Summary

The rotatelogs command is a powerful tool for managing Apache log files. By rotating log files based on time or size, you can ensure that your log files remain manageable and don’t consume excessive disk space. To learn more about Apache VPS hosting and how it can benefit your website, visit Server.HK.

Recent Posts

  • How to Set Up a Reverse Proxy on Hong Kong VPS: Nginx, Multiple Apps, and SSL Management (2026)
  • IPv6 on Hong Kong VPS: Setup, Benefits, and Why It Matters for Asia-Pacific in 2026
  • Hong Kong VPS PostgreSQL Setup: High-Performance Database Configuration for Asia-Pacific (2026)
  • Hong Kong VPS for Live Streaming: RTMP Server Setup and Low-Latency Delivery to China (2026)
  • How to Set Up a Mail Server on Hong Kong VPS: Postfix, Dovecot, and Email Deliverability (2026)

Recent Comments

  1. Hong Kong VPS Uptime and SLA: What 99.9% Uptime Really Means for Your Business (2026) - Server.HK on How to Monitor Your Hong Kong VPS: Uptime, Performance, and Alert Setup Guide (2026)
  2. Best Hong Kong VPS Providers in 2026: Compared by Speed, Routing, and Value - Server.HK on How to Migrate Your Website to a Hong Kong VPS: Zero-Downtime Transfer Guide (2026)
  3. vibramycin injection on How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  4. allopurinol for gout on CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  5. antibiotics online purchase on How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot