Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 am creating a script that backups a mysql db using the mysqldump utility. I am writing this script in the shell "sh". I would like to capture the output status of mysqldump in the script (i.e. if the mysqldump command failed or succeeded) so I can report if the script was successful or not.

  • Does mysqldump return an output status?
  • Can someone please give me instructions on how to do this?
share|improve this question
$ mysqldump .......... && echo "Yes" Replace the ... part with the parameters. If the command is successful it will show Yes otherwise nothing will be shown – Manish Sinha Mar 21 '11 at 14:34
No exitcode/return value is mentioned in MySQL manual or its manual page. Note that sh is a symlink to dash in Ubuntu. – Lekensteyn Mar 21 '11 at 15:21
up vote 1 down vote accepted

You could use bash exit codes.


if $? == 0 then successful else ....
share|improve this answer

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.