1

I'm running a shell script to do various things for me. The idea is to add it to crontab. Here's a sample command to show databases:

EMAILID="[email protected]"

T="/tmp/cleanup.info"

echo "starting backup process at $Now " >> $T


MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"

mysqlport="3306"
mysqluser="someroot"
mysqlpass="pass"
mysqlhost="localhost"

echo "querying the database for record older than date $Lastweekdate " >> $T


DBS="$($MYSQL -u $mysqluser -h $mysqlhost -p$mysqlpass -Bse 'show databases');"

##if noerror then

## echo "success" >> $T
Subject="success"
##else
Subject="failure"
## echo "Backup failed" >> $T

##fi
## rm -f $T

/usr/bin/mail  -s $Subject "$EMAILID" <$T

So as you can see, I have no clue on how to check if the operation was successful or not. Aside from that, everything works perfectly.

Can anyone give me a hand? for reading.

1 Answer 1

0

Check the error return code, It's $?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .