我收到以下错误,但退出代码显示zero
。有没有办法获取数据库错误的退出代码。因为我需要根据exit code
或发送电子邮件警报db error
mysqldump: Couldn't execute 'SHOW FIELDS FROM `v_comloc`': View 'crais.v_comloc' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)
我的尝试
#!/bin/bash -x
mysqldump --opt --routines --single-transaction -p654321 -uroot -hlocalhost crais 2>>/var/log/failedJobs/mysqlCronJob.log |gzip -9 >/userBackupDrive/backupDatabases/crais.sql.gz
RESULT=$?
echo "Output code for $db is : $RESULT "
if [ $RESULT -eq 0 ] ; then
echo
else
echo "$DATE__ $db backup not successful" >> /var/log/failedJobs/dbError.log
fi