Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 0 down vote accepted

Check the error return code, It's $?

share|improve this answer

You must log in to answer this question.

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