How to Split a Linux Log File by Day or Month
Posted on: 08/21/2012 11:44 AM

OCmodshop shows you how to split the Linux log files by day or month

How to Split a Linux Log File by Day or Month

If you’re like me, then you’ve probably set up your Linux server completely wrong! Seriously though, many people who host with Linux probably have some hosting company set their server up. Unless your admins took the extra care to automatically separate your log files by date, then you may have noticed one huge-ass log file in your web page’s directory… especially if it isn’t compressed.

In my case I had an 11.3GB log file sitting in my home directory, and I really needed to split it up into smaller files.

There’s a very easy way to do this with the Linux command line.

Before you can split the file up, you need to go to the path of the log file folder. Depending on how your Linux server is set up, it may be in /var/log/httpd/ or /home/<username>/.

If you actually look at one of the log files, you will see several bits of information. You will notice that the date and time is recorded with each action in this format: [29/Mar/2012:12:00:00 -0700]. Knowing how the date is stored will help you split the files up.

Printed from Linux Compatible (