Header Ads

Breaking News

Manually rotating log files on Linux

Log rotation, a normal thing on Linux systems, keeps any particular log file from becoming too large, yet ensures that sufficient details on system activities are still available for proper system monitoring and troubleshooting.

The oldest in a group of log files is removed, remaining log files are bumped down a notch and a newer file takes its place as the current log file. This process is conveniently automated and the details can be adjusted as needed.

Manual rotation of log files is possible through the use of the logrotate command. This post provides details on how to manually rotate log files and what to expect.

The examples described in this post work on Ubuntu and related Linux systems. Other systems might use different log file and configuration file names, but the process itself should be very similar.

Why rotate a log file

Under normal circumstances, there is no need to manually rotate log files. Your Linux system should already be set up to rotate some logs daily (or less often) and others depending on their size. If you need to rotate a log file to free up space or separate a current log from ongoing activity, it’s fairly easy to do but will depend on your file-rotation specifications.

A little background

A number of log files are set up for rotation as soon as a Linux system is installed. In addition, certain applications add their own log files and rotation specs when they are installed on the system. The configuration files for log-file rotations can be found in the /etc/logrotate.d directory. Details on how this process works are available on an earlier post.

Copyright © 2020 IDG Communications, Inc.

Source link

No comments