LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2003, 11:09 PM   #1
teacup
Member
 
Registered: Mar 2003
Location: Rockford, Illinois
Distribution: Slackware Debian
Posts: 86

Rep: Reputation: 15
log cleanup script


How do I write a cron script that will remove all local connections from my proftd.log and my xferlog files? The lines in the proftpd.log look like this:

Sep 15 21:25:28 teacup proftpd[948] teacup.localhost (12-345-678-91.domain.com[12.345.678.91]): FTP session opened.
...
... // more of the same
...
Sep 21 14:45:48 teacup proftpd[766] teacup.localhost (localhost[127.0.0.1]): FTP session opened.

I want to remove all lines that look like the last one in the file (all the lines with localhost connecting to the server). How would I do this sort of thing?
 
Old 09-24-2003, 01:36 AM   #2
SaTaN
Member
 
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223

Rep: Reputation: 33
type "crontab -e" on the command prompt...
A file will be opened. Place this line in that file



0 0 * * * cat file | awk '{if($7!="(localhost[127.0.0.1]):"){for(i=1;i<=NF;i++){printf $i" "}print""}}' > new_file



file is the path to the proftd.log and the new_file is where you
want it to be stored......

P.S :- This code will be executed at 00:00:00 time everday ....

<edit>
You shouldn't use same file as both "file" and "new_file' . If you want to store in the same log file then,

0 0 * * * cat file | awk '{if($7!="(localhost[127.0.0.1]):"){for(i=1;i<=NF;i++){printf $i" "}print""}}' ; cp new_file file ; rm -f new_file

You should give the full paths to file and new_file


Last edited by SaTaN; 09-24-2003 at 01:51 AM.
 
Old 09-24-2003, 11:32 AM   #3
teacup
Member
 
Registered: Mar 2003
Location: Rockford, Illinois
Distribution: Slackware Debian
Posts: 86

Original Poster
Rep: Reputation: 15
Thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create log file from script fotoguy Programming 12 03-27-2012 06:39 AM
user log in and autoruns script rharris72 Programming 1 11-21-2005 09:14 AM
log on (script?) problem gsabcuk General 2 06-10-2005 05:06 AM
init script won't run at log-off dimangi Linux - Newbie 1 10-29-2003 02:19 AM
A live log monitor script ? ifm Linux - Software 1 07-19-2002 02:54 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration