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="[email protected]"


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

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


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
## echo "Backup failed" >> $T

## 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
add comment

1 Answer

up vote 0 down vote accepted

Check the error return code, It's $?

share|improve this answer
add comment

Your Answer


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.