Search

Log File Unix Commands

Log File UNIX Commands

Summary: One of the biggest parts of my job is managing website log files. Our business is very marketing-centric, so missing log file data isnt expectable. There have been a few situations were log files have been split or broken. Below are three nice little commands which have helped tremendously.

unix commands, log file management, unix log files, apache management, log management, sed command, cat command

Article Body: One of the biggest parts of my job is managing website log files. Our business is very marketing-centric, so missing log file data isnt expectable. There have been a few situations were log files have been split or broken. Below are three nice little commands which have helped tremendously.

Removes all log files with no data find /home/httpd/logs -size -type f -print | xargs - rm f This is a simple little command which helps keep things neat and organized. Once files rotate Ive found a bunch of empty files on the folder. This really confuses some of the marketing people.

Converts log files extention into logical month. for i in `dir /home/httpd/logs/-access_log.|sed s/\.$//`; do mv $i. $i.feb; done A little more complicated. Again, the overall goal here is to make the log files more friendly for marketing people connecting into the FTP server. I am converting the . extension file created by the log rotate into .month. I use this single line to change the extension on + files. Works fantastic!

Combines log files with extentions .. -> . and creates a new logical month. for i in `dir /home/httpd/logs/-access_log.|sed s/\.$//`; do cat $i.. $i. >$i.mar; done Here is the big daddy. One month because of a mistake the log files rotated mid-month. This would have been a nightmare to manually concatenate each file. This script above takes the files and combines them. Try to do this in windows!

For the most part Ive learned to hate access logs. They are a big, always changes, difficult to backup, and from a technical perspective somewhat useless. These little few commands above however make life a little easier.

Shubham Ganeshwadi

Shubham Ganeshwadi

Hi, I’m Shubham Ganeshwadi, Your Blogging Journey Guide 🖋️. Writing, one blog post at a time, to inspire, inform, and ignite your curiosity. Join me as we explore the world through words and embark on a limitless adventure of knowledge and creativity. Let’s bring your thoughts to life on these digital pages. 🌟 #BloggingAdventures

Leave a comment

Your email address will not be published. Email is optional. Required fields are marked *

Your experience on this site will be improved by allowing cookies Cookie Policy