Sponsored Content
Top Forums Shell Programming and Scripting script to grep only the lasts errors Post 302529329 by jblecrou on Thursday 9th of June 2011 05:12:35 AM
Old 06-09-2011
ok, I finally did what I want

I made some adjustments to the previous script so if there's a lot of java heap space I don't receive a lot of mail^^

for info, here it is :

Code:
#!/bin/sh
DIR=/opt/prod/glassfish/domains/domain1/logs
DIR_COUNT=/opt/prod/exploit/domain1/scripts/
MAIL=/usr/ucb/mail
DEST_MAIL=mails@me.com
SUBJ_MAIL="[ALERTE]Java  heapspace was found"
START=0
err_count_file=$DIR_COUNT/count
error_count=`cat $DIR_COUNT/count`
/usr/xpg4/bin/grep -q 'Java heap space'  $DIR/server.log
if [ $? -ne 0 ]
    then echo $START > $DIR/count
fi
count=`grep -c 'Java heap space' $DIR/server.log`
if [ "$count" -gt "$error_count" ]
then
        echo "Java heap space found " | $MAIL -s "$SUBJ_MAIL" $DEST_MAIL &&  echo $count > $err_count_file

else 
	echo $count > $err_count_file && exit 0
fi


Last edited by pludi; 06-09-2011 at 07:27 AM..
 

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
INSTALLSIEVE(1) 					      General Commands Manual						   INSTALLSIEVE(1)

 *

NAME
installsieve - user utility for managing sieve scripts SYNOPSIS
installsieve DESCRIPTION
installsieve is a utility that allows users to manage their sieve scripts kept on the server. OPTIONS
-v <name> View script with the given name. The script if retrieved sucessfully is output to standard output. -l List all of the scripts currently on the server. If one of the scripts is active a arrow is printed indicating that it is the active script. -p <port> Port to connect to. If left off this defaults to "sieve" as defined in /etc/services. -i <file> Install a file onto the server. If a script with the same name already exists on the server it is overwritten. Upon sucessfully putting the script on the server the script is set active. If <file> has the extension .script it is chopped when put on the server since sieve names may not contain a '.'. -a <name> Set <name> as the active script. The list of available names can be obtained from the '-l' option.. -d <name> Delete the sieve script on the server with <name>. -m <mechanism> Force installsieve to use <mechanism> for authentication. If not specified the strongest authentication mechanism is chosen. -g <name> Get the sieve script with <name> and save it to disk with a ".script" extension. If a file with that name already exists it is overwritten. -u <user> Userid/Authname to use for authentication; by default, the current user. CMU
Project Cyrus INSTALLSIEVE(1)
All times are GMT -4. The time now is 04:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy