LVM and VxVM

Trim mail.log to a certain size or upto entered month

 
SOLVED
Go to solution
Tapas Jha
Valued Contributor

Trim mail.log to a certain size or upto entered month

Hi,
Can anyone help me in perl script? I am trying to write perl script which will delete lines above the given date or delete certain lines from above. That means the program will asked the date and will delete lines above that date OR it may asked for no. of lines to be deleted.

Any help will be appreciated. I am using perl 5.8.0 version.

My logfiles look like:
Apr 1 00:00:00 Bombay sendmail[13366]: AAA13366: from=root, size=264, class=0, pri=30264, nrcpts=1, msgid=<200403311830.AAA13366@Bombay.abc.com>, rel
ay=root@localhost
Apr 1 00:00:01 Bombay sendmail[13416]: AAA13366: to=tapas, ctladdr=root (0/3), delay=00:00:01, xdelay=00:00:00, mailer=local, stat=Sent
......
.......
May 1 00:00:00 Bombay sendmail[13366]: AAA13366: from=root, size=264, class=0, pri=30264, nrcpts=1, msgid=<200403311830.AAA13366@Bombay.abc.com>, rel
ay=root@localhost
May 2 00:00:01 Bombay sendmail[13416]: AAA13366: to=tapas, ctladdr=root (0/3), delay=00:00:01, xdelay=00:00:00, mailer=local, stat=Sent

Rgds
Tapa
Tapas Jha
3 REPLIES 3
Geoff Wild
Honored Contributor
Solution

Re: Trim mail.log to a certain size or upto entered month

Why re-invent the wheel?

Look at logrotate:

http://hpux.ee.ualberta.ca/hppd/hpux/Sysadmin/logrotate-2.5/

Logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Tapas Jha
Valued Contributor

Re: Trim mail.log to a certain size or upto entered month

Geoff,

logrotate is perfectly fine. I will install the logrotate. Thanx a lot.
But at the same time i just want to learn perl and that is why i am trying for that. :))
Any help will be good for me.

Rgds
Tapas

Tapas Jha
Michael Tully
Honored Contributor

Re: Trim mail.log to a certain size or upto entered month

There is a perl solution here. I've tried it and it works great.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=554710
Anyone for a Mutiny ?