Re: Monitoring any changes in /var/log/messages to file

This is a discussion on Re: Monitoring any changes in /var/log/messages to file within the Linux Administration forums, part of the Linux Forums category; On Fri, 11 Jul 2003 10:57:37 +0200, Sergiusz Michalski wrote: > Hi! > > Maybe you hav any ...


Go Back   Usenet Forums > Linux Forums > Linux Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-11-2003
Bit Twister
 
Posts: n/a
Default Re: Monitoring any changes in /var/log/messages to file

On Fri, 11 Jul 2003 10:57:37 +0200, Sergiusz Michalski wrote:
> Hi!
>
> Maybe you hav any good idea how to detect any new changes maked in
> /var/log/messages and write it to new separate file. Any script???
>
> I've tried to use diff program but I need to have 2 files to compare so I
> don't think that this is an optional solution.


Untested code follows:


if [ ! -e /tmp/msg.old ] ; then # day1 create reference file
sum /var/log/messages > /tmp/msg.old
fi

sum /var/log/messages > /tmp/msg.sum
diff /tmp/msg.sum msg.old
if [ ! $? ] ; then
cp /var/log/messages /some/where/messages_$(date +%F_%H_%M)
cp /tmp/msg.sum /tmp/msg.old
mail -s "/var/log/messages changed" root < /dev/null
fi
Reply With Quote
  #2 (permalink)  
Old 07-11-2003
Sergiusz Michalski
 
Posts: n/a
Default Re: Monitoring any changes in /var/log/messages to file

thats it, thx

Użytkownik "Bit Twister" <BitTwister@localhost.localdomain> napisał w
wiadomości news:slrnbgtiv2.1ui.BitTwister@wb.home...
> On Fri, 11 Jul 2003 10:57:37 +0200, Sergiusz Michalski wrote:
> > Hi!
> >
> > Maybe you hav any good idea how to detect any new changes maked in
> > /var/log/messages and write it to new separate file. Any script???
> >
> > I've tried to use diff program but I need to have 2 files to compare so

I
> > don't think that this is an optional solution.

>
> Untested code follows:
>
>
> if [ ! -e /tmp/msg.old ] ; then # day1 create reference file
> sum /var/log/messages > /tmp/msg.old
> fi
>
> sum /var/log/messages > /tmp/msg.sum
> diff /tmp/msg.sum msg.old
> if [ ! $? ] ; then
> cp /var/log/messages /some/where/messages_$(date +%F_%H_%M)
> cp /tmp/msg.sum /tmp/msg.old
> mail -s "/var/log/messages changed" root < /dev/null
> fi



Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:19 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0