Get notified by email using mailx

Very simple script to get notified by email on job completion. Mostly I use this script for background jobs ran through ‘nohup’.

test.sh
#!/bin/ksh
export FILE=/home/oracle/test.log
sqlplus “/as sysdba” @test.sql
mailx -s “test” raheel@company.com < $FILE

test.sql
spool test.log
select name from v$database;
spool off
exit

Now test the script as

$ nohup sh test.sh >> test.out 2>&1 &

Check your inbox

Cheers !

Raheel Syed

 

Advertisements

About Raheel Syed

Oracle DBA
This entry was posted in Linux, Shell Scripting and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s