Log File UNIX Commands
Log File UNIX Commands

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.strongRemoves All Log Files With No Datastrongcodefind Homehttpdlogs -size 0 -type F -print0 Xargs -0 Rm FcodeThis 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.strongConverts Log Files Extention Into Logical Month.strongcodefor I In Dir Homehttpdlogs-accesslog.1sed S.1; Do Mv I.1 I.feb; DonecodeA 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!strongCombines Log Files With Extentions .1.1 - .1 And Creates A New Logical Month.strongcodefor I In Dir Homehttpdlogs-accesslog.1sed S.1; Do Cat I.1.1 I.1 I.mar; DonecodeHere 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.