Important alert: (current site time 7/15/2013 9:29:29 PM EDT)
 

VB icon

Clear WIN NT event log

Email
Submitted on: 7/30/2000 12:38:08 AM
By: Found on the World Wide Web 
Level: Intermediate
User Rating: Unrated
Compatibility: 5.0 (all versions), 4.0 (all versions), 3.0 (all versions), Pre 3.0
Views: 10303
 
     Clears out events in the WinNT event log - System, Security, and Application logs - and creates a backup copy, optionally gzip'ing it, if you have gzip installed
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
=**************************************
= Name: Clear WIN NT event log
= Description:Clears out events in the WinNT event log - System, Security, and
Application logs - and creates a backup copy, optionally gzip'ing
it, if you have gzip installed
= By: Found on the World Wide Web
=**************************************

#!/usr/bin/perl
use Win32::EventLog;
use Time::CTime;
use strict;
my $VERSION = '1.00';
my ($Event, @timearray, $filename,
$day, $month, $directory);
# Where do you want to put the backup files?
$directory = 'c:/EventLogs/';
for ('System', 'Security', 'Application')	{
	$Event = new Win32::EventLog ("$_", "");
	@timearray=localtime(time);
	$month = sprintf ('%.2d', $timearray[4] +1);
	$day = sprintf ('%.2d', $timearray[3]);
	$filename = $directory . ($timearray[5]+1900) . '_' .
	 $month . '_' . $day . '_' . $_ . '.events';
	$Event->Clear($filename);
	`gzip -9 $filename`;
} # End for
=head1 NAME
ClearEvents - Clear out the events in the WinNT event log, and create
a backup copy, optionally gzip'ing it, if you happen to have 
gzip installed.
=head1 DESCRIPTION
Clear out the events in the WinNT event log, and create
a backup copy, optionally gzip'ing it, if you happen to have 
gzip installed.
There's nothing fancy going on here - the main part of this
is directly from the Win32::EventLog docs.
I run this via cron on some of my NT machines that have a nasty
habit of filling up the event logs every few days. Security 
policy requires that we keep 6 months worth of logs.
=head1 PREREQUISITE
uses Win32::EventLog and Time::CTime
=head1 COREQUISITE
None
=head1 README
Clears out events in the WinNT event log - System, Security, and
Application logs - and creates a backup copy, optionally gzip'ing
it, if you have gzip installed.
=head1 To Do
Instead of using gzip, I'm planning to use Amine's PerlZip package.
=head1 Author
Rich Bowen - <rbowen@rcbowen.com>
=pod OSNAMES
MSWin32
=pod SCRIPT CATEGORIES
Win32
=cut


Other 100 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.