Sponsored Content
Top Forums Shell Programming and Scripting script to grep only the lasts errors Post 302528413 by itkamaraj on Tuesday 7th of June 2011 05:35:47 AM
Old 06-07-2011
create a file called /tmp/count and enter 0

Code:
DIR=/opt/appli/glassfish.prod/domains/domain1/logs
MAIL=/usr/ucb/mail
DEST_MAIL=mail@me.com
SUBJ_MAIL="alert java heapspace blablabla"
################added newly##############
err_count_file="/tmp/count"
error_count=`cat $err_count_file`
count=`/usr/xpg4/bin/grep -c 'Java heap space' $DIR/server.log`
if [ "$count" -gt "$error_count" ]
then
  echo "alerte java heapspace was found" | $MAIL -s "$SUBJ_MAIL" $DEST_MAIL
  echo $count > $err_count_file
else
 exit 0
fi

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

errors using grep

heres the line i think is giving me the error. any help is appreciated. code: if or posibly; while || error : usage: grep -e pattern_list... usage: grep -f... (2 Replies)
Discussion started by: pbonilla
2 Replies

2. Shell Programming and Scripting

Remove lasts characters from a string

Hi all, Consider i have a directory /tmp/test and inside this directory i have the following files: 1.svf.tmp 2.svf.tmp 3.svf.tmp How can i remove the last four characters of every file in irder for the directory to be as: 1.svf 2.svf 3.svf I use the following command but id doesn't... (6 Replies)
Discussion started by: chriss_58
6 Replies

3. Shell Programming and Scripting

Script to capture errors

Hello; I'm trying to write a script to capture any hardware error from logs/syslog on my SUSE 10 servers so i can be notified if we have any hardware issues such a bad fan or battery, etc.. Thanks in advance for any help (2 Replies)
Discussion started by: Katkota
2 Replies

4. Shell Programming and Scripting

Help with shell script errors

hey watsup guys i am new in the shell script world. so i need help fom you guys, i have written these two codes and they both give the same errors( expr : syntax error). Code 1 : #! /bin/sh # count1 appends an increment to a file 200 times # note that a file called numbers must be... (5 Replies)
Discussion started by: surubi_abada
5 Replies

5. Shell Programming and Scripting

ftp script : list 4 lasts files

Hi, At work we have backups on a ftp. I want to view 4 last files saved (their names, dates, and weight). how can i achieve this goal using simplest way ? Thank's. (3 Replies)
Discussion started by: simon974
3 Replies

6. Shell Programming and Scripting

purge logs, keep the 30 lasts

Hi, I have to make a script to purge logs in a directory (this script will run automatically every day) and this script has to keep just the 30 last files. So I want it to count all the files in the directory, find the 30 most recents and delete the others. I just started shell scripting and... (4 Replies)
Discussion started by: jblecrou
4 Replies

7. Shell Programming and Scripting

Help with execution errors in script

solution found.... Please use tags for scripts, listings, and console output (2 Replies)
Discussion started by: audiolord
2 Replies

8. UNIX for Dummies Questions & Answers

How to ignore errors in script

I have a simple script that processes files. Here's a simplified example of what I'm doing: foreach t (web.*) mv $t dnw$t:e.log end foreach t (card.*) mv $t card$t:e.log end The problem is that sometimes there is no web.* file. In that case, I get an error "foreach: No match" and... (4 Replies)
Discussion started by: software5723
4 Replies

9. Shell Programming and Scripting

How to grep logs for errors and receive specific additional lines?

Hi there, I have a script that I've used to find errors in my Minecraft Server logs. But I'd like to refine that script to be more useful. Here is the script: grep -n "SEVERE" /minecraft/server.log | awk -F":" '{print $1-2 "," $1+10 "p"}' | xargs -t -i sed -n {} /minecraft/server.log >>... (15 Replies)
Discussion started by: nbsparks
15 Replies

10. Shell Programming and Scripting

Script to grep logs for Errors

Hi Guys, I want to write a script which can grep the logs (server.log) from a file for Error String and output to a other file. Problems: How to know about the errors only between the current restart and not in previous as server.log has earlier restarts also? thanks for the help! Much... (5 Replies)
Discussion started by: ankur328
5 Replies
CRASH(8)						    BSD System Manager's Manual 						  CRASH(8)

NAME
crash -- examine and debug system images SYNOPSIS
crash [-M core] [-N kernel] DESCRIPTION
The crash command is used to examine and debug system images. If run without any arguments, crash operates on the running system. The options are as follows: -M core Operate on the specified crash dump instead of the default /dev/mem. Crash dumps should be from the same version of the system and same machine architecture as the running version of crash, and must be uncompressed. -N kernel Extract the name list from the specified kernel instead of the default /dev/ksyms. The command syntax used by crash is the same as the in-kernel debugger. See the ddb(4) manual page for more information. Operations and facilities that require a running system, such as breakpoints, are not supported by crash. crash does not provide pagination. However, by using the pipe symbol, output may be sent to commands available from the shell. For example: crash> ps | more crash> ps | grep ioflush SEE ALSO
ps(1), vmstat(1), ddb(4), pstat(8) HISTORY
The crash command appeared in NetBSD 6.0. BSD
March 7, 2009 BSD
All times are GMT -4. The time now is 01:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy