Crobjob Script to Email if Problem Found


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Crobjob Script to Email if Problem Found
# 1  
Old 07-25-2010
Crobjob Script to Email if Problem Found

I have a script that runs in cron twice every hour. My question is, when this script finds an error and sends an email on that error, and the error recovers

how do i make the script only email when there's a problem and also when there's a recovery for that problem?

simply inserting a "mail -s ....." in front of the command will send out an email with EVERY output from the script. this isn't what i need.

i want the script to send an email out to whomever i tell it to, only when an occurrence of an error is found in a file, and when that error has cleared (enough time passes and that alert didn't reoccur).

makes sense?

please help.

thank you

Last edited by SkySmart; 07-25-2010 at 04:48 PM..
# 2  
Old 07-26-2010
Generate a specific file output if you want to sent mail, then
Code:
file=/tmp/hari/mailcontext.txt
if [ -f $file ] ; then
cat $file | mailx -s "ALERT!!!" -r $REPLYTO -c "$MAILCC" -b $MAILBB $MAILTO
rm $file
fi

# 3  
Old 07-26-2010
I usually do something like this...

Code:
blah
blah
blah
[ $all_is_ok ] && exit  # exit if all is well

mailx -s oops user << EOF

message here.
do a command?

$(date)
$(cat error_file)

EOF

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Problem with Script to email Admin users with expired passwords writed byygemici

Hi, I have problem with a script, it was working for 6 month and suddenly I started getting strange expire times example: # chage -l wXXp Last password change : Oct 28, 2014 Password expires : Nov 27, 2014 Password... (3 Replies)
Discussion started by: redmansas
3 Replies

2. Shell Programming and Scripting

Autorep not found problem

Hi All, I am using a putty session to login a server in which autosys is installed. we get the GUI by entering . /opt/CA/UnicenterAutoSysJM/autouser/autosys.ksh.server and then jobscape. when i tried autorep -j jobname it gives me autorep not found. Please help me with this. (1 Reply)
Discussion started by: mahesh300182
1 Replies

3. Shell Programming and Scripting

sending email in case of file not found

Hi, In the shell script, i want to do sftp and go to a directory and check if a particular file is present, if not i send an email with some error message. Please guide me about how i could achieve it...." (1 Reply)
Discussion started by: sJohn
1 Replies

4. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

5. Shell Programming and Scripting

help with script to send email and if subject line match is found

Help with script that will check log, then find a match is found, add that as the subject line. 1. The script will always run as a deamon.. and scan the event.log file 2. when a new 101 line is added to the event.log file, have the script check position 5,6 and 7 which is the job name, which... (2 Replies)
Discussion started by: axdelg
2 Replies

6. Solaris

E3500 Harddisk not found problem (First time user)

I'm first time user on Enterprise 3500 and got some problem, that I try to install Solaris 9 on this machine (and it work fine on Sun U10) it not found harddisk in fdisk command on 'ok prompt' I try probe-scsi-all but it show only Tape and CDrom in this machine I install 2 harddisk in... (2 Replies)
Discussion started by: Harmut
2 Replies

7. Shell Programming and Scripting

Scripting problem - when the file is not found i want it to return to the menu

when the file is not found i want it to return to the menu, however it carries out the next line when i hit a key I know its probably something simple can anyone help? here is my pause function: function pause(){ read -s -n 1 -p "Press any key to return to Menu . . ." echo } SCRIPT... (2 Replies)
Discussion started by: Alendrin
2 Replies

8. Shell Programming and Scripting

Problem with script: ksh not found

Hello Guys, what is the significance of using #!/bin/sh at the start of shell script. my default shell is ksh, when i run my script i have ksh: not found error and when i use ./myscript it works. Can anyone explain me the problem please ? tnx (1 Reply)
Discussion started by: midhun_u
1 Replies

9. UNIX for Dummies Questions & Answers

No screens found problem - and I cant use keybord properly to solve!!

Title explains it already. I need to solve the problem from log files. But backspace types ^H . I dont know how to delete character. How can I mend the keybord ? (1 Reply)
Discussion started by: olddays
1 Replies

10. AIX

Problem MAKE cc: not found on AIX 5.3 please help me...

Hi guys, I am trying to install Big Brother monitoring on my box p570 AIX5.3ML2. But the after the installation you must run a make and it is failed see below the message: /home/bb/bb1.9h-btf/src/ # make Making aix makefile BBOS="aix" CC="cc" CFLAGS=" -Daix -DTIMEH -DREGEXEC... (1 Reply)
Discussion started by: touny
1 Replies
Login or Register to Ask a Question