View Single Post
Old 01-21-2006, 09:36 AM   #4 (permalink)
philg
 
Junior Techie

Join Date: Nov 2005

Posts: 74

philg

Default

No it wouldn't send the sql file by email.

You can set the MAILTO directive in the crontab to have output from cronjobs sent to you, or you can pipe the output of the command through mail and send it to you that way.

If you just want a Success or Failure in your email then you'll have to catch exit codes, normally programs should return 0 on a successful execution, you should check all your commands to make sure. example:

Code:
#!/bin/bash

EXIT_STATUS_TOTAL=0

command one
EXIT_STATUS_TOTAL=$[ $EXIT_STATUS_TOTAL + $? ]
command two
EXIT_STATUS_TOTAL=$[ $EXIT_STATUS_TOTAL + $? ]
command three
EXIT_STATUS_TOTAL=$[ $EXIT_STATUS_TOTAL + $? ]

if [ $EXIT_STATUS_TOTAL -eq 0 ]; then
    RESULT="Success"
else
    RESULT="Failure"
fi
echo $RESULT | mail -s "SQL Backup" you@somewhere.com
exit 0

__________________
www.pdgaskell.co.uk
philg is offline