문제

i wrote a script that make a dump of mysql dbs, i need to check if the command succfully executed or not. using $? give me always 0 even if there are a connection problem with the db server. any idea how can i do this thanks

도움이 되었습니까?

해결책

Script

#!/bin/sh
mysqldump -h 192.168.1.10 -u user -pPaSSwOrD dbname > filename.sql
if [ "$?" -eq 0 ]; then
    echo "Success"
else
    echo "Error"
fi

is successfully showing errors for connection timeouts, wrong dbname, wrong username and password. It only doesn't check integrity of dump taken, but it's another story.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top