LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-10-2011, 09:20 PM   #1
saran_redhat
Member
 
Registered: May 2009
Location: chennai
Posts: 247

Rep: Reputation: 16
Log Files


HI,

Is there any way to find out log files increases we will get automatic email alert. for example if the log file size is 2 MB once the file exceeded 2MB then we will get email alert. is there any script. please advise me. Thanks.

Last edited by saran_redhat; 03-10-2011 at 11:33 PM.
 
Old 03-11-2011, 12:45 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
What kind of log files are you talking about?
 
Old 03-11-2011, 05:17 AM   #3
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,528

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
You could use something like
Code:
#!/bin/bash
cd <to your location of the logfiles>
for FILE in * ; do
SIZE=`/bin/ls -l $FILE | /bin/awk '{ print $5 }'`
if (( $SIZE > 10000 )) ;then
echo $FILE is to big | mail -s $FILE you@you.com
fi
done
Kind regards
 
Old 03-11-2011, 05:30 AM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Quote:
Originally Posted by repo View Post
You could use something like
Code:
#!/bin/bash
cd <to your location of the logfiles>
for FILE in * ; do
SIZE=`/bin/ls -l $FILE | /bin/awk '{ print $5 }'`
if (( $SIZE > 10000 )) ;then
echo $FILE is to big | mail -s $FILE you@you.com
fi
done
Kind regards
You win this round... I'm at work as usual and I'm not around linux at the moment.... LOL
 
Old 03-11-2011, 05:35 AM   #5
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 13.1
Posts: 1,328

Rep: Reputation: 254Reputation: 254Reputation: 254
What kind of logfile is it? Can it be rotated by logrotate, where you also can send emails in the pre-/postrotate entry in case it occurs?
 
Old 03-13-2011, 09:45 PM   #6
saran_redhat
Member
 
Registered: May 2009
Location: chennai
Posts: 247

Original Poster
Rep: Reputation: 16
Log Files

Quote:
Originally Posted by Reuti View Post
What kind of logfile is it? Can it be rotated by logrotate, where you also can send emails in the pre-/postrotate entry in case it occurs?
Hi


Great this works fine.

for example If I want to check mail and httpd logs. It shows all the log files in the directory. but i need current log files.
How i do this. any suggestions.

Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Configure mysql InnoDB to use data files or log files on NFS volumes?? novice32 Linux - Software 4 04-15-2010 08:15 PM
Firewall log file, how to make several different log files with IPTables? newtovanilla Linux - Newbie 5 11-28-2008 12:39 PM
vsftpd and log files - can i up the log level to see login attempts? robr Linux - Newbie 3 04-04-2008 11:38 AM
Deleted /var/log/messages, can't log any files-iptables chingyenccy Linux - Newbie 7 02-27-2005 04:03 PM
Can log files be time stamped? (such as FTP login and transfer log files) bripage Linux - Networking 6 08-08-2002 10:55 PM


All times are GMT -5. The time now is 02:52 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration