Notify as soon as an error is encountered in a script
Hi,
The script below works okay and emails me the log in the end once the script completes but what I'm trying to do is to also notify me via an email as soon as the script encounters any error whatsoever.
The script below works okay and emails me the log in the end once the script completes but what I'm trying to do is to also notify me via an email as soon as the script encounters any error whatsoever.
Thanks,
mbak
Please be more explicit about what errors you want to cause to send an additional email.
Is it an error that you are invoking replacepv with three operands while the man page only specifies what happen when two operands are given? For example, when you read the 1st line from test.list (setting DISK1 to hdisk0), you will be running the command:
Is that an error? Does the above replacepv command complete successfully? Does it print any diagnostic messages? Does it write anything into ERR.OUT?
Is it an error when your grep command matches two or more lines and you only process one of those lines? For example, when you read the 2nd line from test.list, the command:
will match the following lines from NEWDISK.list:
but you only read the 1st matched line and run the command:
ignoring the 2nd line and not running the command:
Is that an error? Or, is it an error that the above grep command matched hdisk10 on the 2nd line when it should not match hdisk10 when I assume you only wanted exact matches for the word hdisk1?
Or, did you just want to mail any lines appended to ERR.OUT (even though ERR.OUT does not contain any diagnostic messages that might have been written to explain what errors had been detected)?
My apologies for missing out a value in the script, it should have been as below,
Since I'm replacing multiple disks, I want to get an email or I can set it up to send an alert whenever the "replacepv" command fails for any reason like disk not found or something before trying to run "replacepv" on next disk in sequence in other words notify me as soon as it fails at any point during the script execution. I noticed that ERR.OUT doesn't log anything if I use a disk that doesn't exist which throws an error on screen.
What system hardware are we talking about?
What RAID controller?
Are you asking....
How to interrogate the RAID controller?
How to trap the error in the script?
When you say to mail you as soon as it fails are you saying that you want to receive an email that very second? Email systems (daemons) don't work that fast. The mail relays don't work that fast depending if your inbox isn't on the same system. It could take a few minutes.
---------- Post updated at 09:38 AM ---------- Previous update was at 09:36 AM ----------
This may work, assuming I understand your requirements correctly.
Add the following lines to the start of your program:
What should now happen is that if the disk replacement program fails, an ERROR signal is sent to the process running your script, and it will run the function err_code, then exit.
The command set -e tells the shell to exit with an error if a command fails (you may want to put your loop, or just the sudo line, between a set -eset +e pair of commands so that other commands don't execute the err_code function). This isn't enough, however, as the tee command will exit with no error. So set -o pipefail command will cause the pipeline to fail if the sudo fails.
Hi,
I am having issues with the jar -tf command when I put in the shell script.
The command runs fine from the command line as shown below.
# jar -tf "./VirtualBox Dropped Files/2016-04-17T20:58:49.129139000Z/hive-exec-0.8.1.jar"
But when I put in a shell script(shown below) and the... (10 Replies)
Hi All
I am trying to write a shell script that will notify via email if a particular service is down. What I have so far is a script in cron like his:
#!/bin/sh
cd /usr/jdk/instances/jdk1.6.0/bin/sparcv9
jps -m
And the output of the above is
81529 Jps
52988 TaskControllerService... (5 Replies)
Hello,
How can I add a logic to awk to tell it to print 0 when encountering a division by zero attempted? Below is the code. Everything in the code works fine except the piece that I want to calculate read/write IO size. I take the kbr / rs and kbw / ws. There are times when the iostat data... (5 Replies)
Hi the following script let sthe user know whenevr any file is changed inserted or deleted in file system.
but i am getting following error while running bash script
## LINUX SYSTEM FILE ARCHIVE NOTIFY ##
if ; then echo "Usage '$0 folder waitseconds' " ; exit 1; fi
if ; then echo "Folder... (1 Reply)
Hi experts,
Need help on the below error please.
I am creating Filesystem and it fails with the below errors :(
Command: failed stdout: yes stderr: no
Before command completion, additional instructions may appear below.
0518-506 odmget: Cannot open object class PdAt
... (10 Replies)
Hi,
I am having a little trouble getting notify-send to work the way I would like it to.
I am using ubuntu - karmic koala 2.6.31-19-generic #56-Ubuntu SMP
So here's the problem
run the following commands one after the other.
notify-send -i info -t 100000 -- "Hi" "world" &
notify-send -i... (3 Replies)
I have a server and occasionally the file mysqld.log would show something like
/usr/libexec/mysqld: Disk is full writing './example_com_-_wordpress/wp_statpress.MYD' (Errcode: 122). Waiting for someone to free space... Retry in 60 secs
How do I write a simple shell script to check mysqld.log... (1 Reply)
Can someone please help me with this script, I'm trying to create system backup on AIX, for this I want to first mount the filesystem if it is not mounted, then create the backup and unmount the filesystem but I'm having problem while using the mail command to notify the status of filesystem... (9 Replies)
Hi Experts,
I am trying to write a ksh script that it should notify in case there is no response from the other script. I mean to say that I got a.sh and b.sh
the execution of b.sh depends on a.sh, so if there is no response from a.sh,
b.sh should notify me about the same.
Thanks in Advance (4 Replies)
I used this on an AIX machine and encountered the following error.
$ ls -l
total 600
-rwxrwxrwx 1 e26936 dba 1491 Feb 07 1992 MANIFEST
-rwxrwxrwx 1 e26936 dba 8148 Apr 05 1992 Makefile
-rwxrwxrwx 1 e26936 dba 4852 Sep 06 2003 README
-rwxrwxrwx... (0 Replies)