Search:       

Saturday, 30 August 2008       

 
Home / Computers / Software

Log File UNIX Commands

By:Atlas-Tuesday


One of the biggest parts of my job is managing website log files. Our business is very “marketing-centric”, so missing log file data isn’t 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 0 -type f -print0 | xargs -0 rm –f

This is a simple little command which helps keep things neat and organized. Once files rotate I’ve 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.1|sed s/.1$//`; do mv $i.1 $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 *.1 extension file created by the log rotate into *.month. I use this single line to change the extension on 300+ files. Works fantastic!



Combines log files with extentions .1.1 -> .1 and creates a new logical month.

for i in `dir /home/httpd/logs/*-access_log.1|sed s/.1$//`; do cat $i.1.1 $i.1 >$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 I’ve 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.



Article Source: http://www.dailynewarticles.com

Atlas-Tuesday - Log File UNIX Commands








More Articles from Software Category:
Easy Computer Privacy
Guard and Lock Your Files Making them Invisible
Protect Photos, Pictures and Videos
Tips For Selecting Editing Software For Construction
Spam Attack - How to Combat Spam
Two Easy Ways To Fix PC Bugs
Business Software – Adding Efficiency To Business
How to Improve Productivity and Automate Everyday Computer Tasks with Windows Automation Software.
DVD Copy Software And Your Life
Open Source Content Management Software Solutions
Many Employers and Schools Are Using Software Testing
Software Downloads
The Cheapest Software Is At…
Advanced Process Control Increases Profits
This Year, Try Using Tax Software to File Your Taxes

 


Main Menu
Home
Most Popular Articles
Top Authors
Submit Articles
Submission Guidelines
Link to Us
Bookmark
Contact Us

Partners
Blue Articles

 

 

- Privacy Policy -