Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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="some@Gmail.com"

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.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Check the error return code, It's $?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.