LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 08-27-2012, 08:46 PM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 30
Check error


I have a server log which have many message appending to it , I would like to check if there is error in the log .

can advise how to write a script to check the last 100 lines of the log , if the message "the server error" appears , then send the mail to administrator , can advise the script ?

thx
 
Old 08-27-2012, 08:54 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
After 1000+ posts I would think you would know to at least write a script and try it, then come back if you get stuck.
You'll need to show us the code and the error msgs, if any.
Hints; look into tail, grep, mailx cmds.
 
1 members found this post helpful.
Old 08-27-2012, 09:35 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,990

Rep: Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316
Couldn't agree more....op, can you ever post some of your efforts, rather than just asking for handouts? After NINE YEARS, you should know how to put a script together, and how to post a question. See previous thread where that was suggested, which links to several others:

https://www.linuxquestions.org/quest...pt-4175423170/

Last edited by TB0ne; 08-28-2012 at 01:02 PM.
 
Old 08-27-2012, 09:48 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,208

Rep: Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611
Simple oneliner:

Code:
tail -n 100 somelog.txt | grep -q 'error'; if [[ $? -eq 0 ]]; then mail -s "Something wrong" you@yourdomain.com; fi
Something more elegant could be done. But this is what you get for free.
 
  


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
Error msg: error: C++ preprocessor "/lib/cpp" fails sanity check wild_willy Linux - Newbie 4 01-04-2007 11:30 AM
Error Check XPediTioN Slackware 7 09-22-2004 08:20 AM
check out this error vyeperman3001 Linux - Software 6 02-20-2004 08:30 PM
gcc-3.3.1 make -k check - make [check] Error 2 BarryM45 Linux From Scratch 1 02-05-2004 08:44 AM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 02:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:00 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