Register
It is currently Wed Oct 22, 2014 8:19 pm

script to monitor logs


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sat May 10, 2008 4:19 pm   

Joined: Fri May 09, 2008 11:26 pm
Posts: 2
Im wanting a script that monitors apache access and error logs and notifies me with a pop up like notify-send. i have one with zenity but zenity doesn't have popups but heres what im using thus far.

Code:
tail -f /var/log/apache2/access.log & tail -f /var/log/apache2/access.log | zenity --title "Apache Log Viewer" --text-info --width 1024 --height 800


i wouldn't even need such a thing, but this person wants this to run on startup and have a gui, so any ideas would be great. thanks.


Top
 Profile  
 PostPosted: Fri May 16, 2008 2:41 pm   
User avatar

Joined: Sun Apr 13, 2008 4:05 am
Posts: 37
Location: /dev/random
if you want to monitor new logs, something like this may help you
Code:
#!/bin/bash
if [ ! -f /tmp/logcopy ]
then
  echo "first run, copying log file"
  cp /var/log/apache2/access.log /tmp/logcopy
fi
oldfilehash=`md5sum /tmp/logcopy | cut -d " " -f1`
newfilehash=`md5sum /var/log/apache2/access.log | cut -d " " -f1`
if [ "$oldfilehash" != "$newfilehash" ]; then
diff /var/log/apache2/access.log /tmp/logcopy > /tmp/logdiff
if [ ! $? -eq 0 ]; then
cat /tmp/logdiff | zenity --title "Apache Log Viewer" --text-info --width 1024 --height 800
fi
cp -u /var/log/apache2/access.log /tmp/logcopy
fi
exit


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP