Sponsored Content
Top Forums Shell Programming and Scripting grep only last occurred error in error.log, Post 302437235 by tapia on Wednesday 14th of July 2010 11:14:07 AM
Old 07-14-2010
grep only last occurred error in error.log,

hi folk i need your help to find one logic....

i have error log same as any other error logs which get populated by no of events and errors...

but i need to grep the last occured errors.. which cant be duplicate.

here is my script.
========================
Code:
#!/usr/bin/ksh
grep -i "STOP" $BATE/err.log > /tmp/bbs.lst   --capture error into tmp 
checkFile=/tmp/bbs.lst               
if [ -e $checkFile ]; then        ----if file is not empty 
mailx -s  'errors' XYZ@gmail.com < $checkFile
else
echo "dont worry process is fine" > /tmp/bbr.log   ---throwing into dump 
fi
rm -rf /tmp/bbs.lst       -----removing tmp

====================================

now problem is if i wake up this script every 2 min ,,
i need to check last 2 min errors which is in $BATE/err.log and sending to
/tmp/bbs.lst

suppose if it capture one error at 9:30 pm
after sometime if the script is wakup at 9:32 pm
and find again that same error which occured at 9:30 pm

so i want to capture the errors but dont want to duplicate it..

my err.log format will be something like this one

====================================================
Code:
2010-07-09 10:11:07  bb ERROR  250   XX.rm:  PROCESS STOP
2010-07-09 10:12:48  bb ERROR  250   XX.rm:  PROCESS STOP
2010-07-09 12:38:33  bb ERROR  250   XX.rm:  PROCESS STOP
2010-07-09 17:05:02  bb ERROR  250   XX.rm:  PROCESS STOP

can you guys help me in this ???

Last edited by vgersh99; 07-14-2010 at 12:21 PM.. Reason: code tags, please!
 

8 More Discussions You Might Find Interesting

1. Red Hat

rhn_register A socket error occurred

All, I'm getting the following error while I try to register the server to connect the redhat network for the updates. rhn_register updateLoginInfo() login info rhn_register A socket error occurred: (111, 'Connection refused'), attempt #1 rhn_register A socket error occurred: (111,... (6 Replies)
Discussion started by: s_linux
6 Replies

2. Shell Programming and Scripting

sort: 0653-657 A write error occurred while sorting.

Hi I am trying to sort a file of 88075743B size. I am doing some processing on the file and after the processing is done; I get 2 files temp1 and temp2. I need to combine both these files as one and this final file should be sorted on fields 1 and 2. Space is the delimiter between fields. Record... (2 Replies)
Discussion started by: diksha2207
2 Replies

3. Shell Programming and Scripting

Log file is not getting created & unable to grep error from it

Hi All, Below is my code,what I am trying to do is redirecting output of ftp to a log file & then greping the errors but here I am unable to grep "Permission denied" error only & also the corresponding log file is also not getting created. #!/bin/sh . cfg USER='abc' PASSWD='abc123' ... (4 Replies)
Discussion started by: ss_ss
4 Replies

4. Red Hat

KusuDB: Operational Error occurred when connecting to the DB

I have RHEL5.3 that is with the Platform Cluster Manger PCM installation. on master node. Unfortunately some files were deleted from the /var directory and then the postgresql service couldn't start. I have deleted, rm -rf /var/lib/pgsql/data and started the service again now the service is running... (1 Reply)
Discussion started by: ahsanpmd
1 Replies

5. Solaris

Error occurred while making the net-snmp 5.4.4 on Solaris 5.10 version.

Hi all, Error occurred while making the net-snmp-5.4.4 on Solaris 5.10 version. Environment - Solaris 5.10-x86 - Net-SNMP-5.4.4.tar.gz - Path (/etc/profile) PATH=/usr/local/bin:$PATH export PATH LD_LIBRARY_PATHUSR=/usr/ccs/bin: export LD_LIBRARY_PATH Error01 - summary ***... (3 Replies)
Discussion started by: ziosnim
3 Replies

6. AIX

0511-193 An error occurred

Hi, When i am trying to read data from tape cassette its giving below error: tar tvf /dev/rmt0 "tar: 0511-193 An error occurred while reading from the media. A system call received a parameter that is not valid." OS: - AIX 6.1 Tape Library : - IBM TS3100 Tape Cassette : - Ultrium LTO... (1 Reply)
Discussion started by: arunmistry
1 Replies

7. Shell Programming and Scripting

Error occurred during initialization of VM

Hi , I was invoking a sh file using the nohup command. But while invoking, I received a below error. Error occurred during initialization of VM Unable to load native library: /u01/libjava.so: cannot open shared object file: No such file or directory . Could you please help out. Regards,... (2 Replies)
Discussion started by: Kamal1108
2 Replies

8. UNIX for Beginners Questions & Answers

Print Error in Console and both Error & Output in Log file - UNIX

I am writing a shell script with 2 run time arguments. During the execution if i got any error, then it needs to redirected to a error file and in console. Also both error and output to be redirected to a log file. But i am facing the below error. #! /bin/sh errExit () { errMsg=`cat... (1 Reply)
Discussion started by: sarathy_a35
1 Replies
SAVE_BINARY_LOGS(1p)					User Contributed Perl Documentation				      SAVE_BINARY_LOGS(1p)

NAME
save_binary_logs - Concatenating binary or relay logs from the specified file/position to the end of the log. This command is automatically executed from MHA Manager on failover, and manual execution should not be needed normally. SYNOPSIS
# Test $ save_binary_logs --command=test --binlog_dir=/var/lib/mysql --start_file=mysqld-bin.000002 # Saving binary logs $ save_binary_logs --command=save --binlog_dir=/var/lib/mysql --start_file=mysqld-bin.000002 --start_pos=312 --output_file=/var/tmp/aggregate.binlog # Saving relay logs $ save_binary_logs --command=save --start_file=mysqld-relay-bin.000002 --start_pos=312 --relay_log_info=/var/lib/mysql/relay-log.info --output_file=/var/tmp/aggregate.binlog save_binary_logs concatenates binary or relay logs from the specified log file/position to the end of the log. This tool is intended to be invoked from the master failover script(MHA Manager), and manual execution is normally not needed. DESCRIPTION
Suppose that master is crashed and the latest slave server has received binary logs up to mysqld-bin.000002:312. It is likely that master has more binary logs. If it is not sent to the slave, slaves will lose all binlogs from mysqld-bin.000002:312. The purpose of the save_binary_logs is to save binary logs that are not replicated to slaves. If master is reachable through SSH and binary logs are readable, saving binary logs is possible. Here is an example: $ save_binary_logs --command=save --start_file=mysqld-bin.000002 --start_pos=312 --output_file=/var/tmp/aggregate.binlog Then all binary logs starting from mysqld-bin.000002:312 are concatenated and stored into /var/tmp/aggregate.binlog. If you have binary logs up to mysqld-bin.000004, the following mysqlbinlog outputs are written. mysqld-bin.000002:Format Description Event(FDE), plus from 312 to the tail mysqld-bin.000003:from 0 to the tail, excluding FDE mysqld-bin.000004:from 0 to the tail, excluding FDE perl v5.14.2 2012-01-08 SAVE_BINARY_LOGS(1p)
All times are GMT -4. The time now is 11:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy