• 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

  • What Is CentOS? A Complete Beginner’s Guide to CentOS Linux in 2026
  • Debian Server Troubleshooting Checklist
  • How to Configure a Firewall on a Debian Server: Theory and Best Practices
  • Debian Boot Process Explained
  • Secure SSH Configuration on Debian Server: Theory and Best Practices

Recent Comments

No comments to show.

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