Kaptain.
Telegram /
LinkedIn /
Email /
GIT /
RSS /
GPG /

№ 10430 В разделе
Sysadmin
от December 6th, 2019,
В подшивках: Bash, MySQL, PostgreSQL
You can easily use it to check MySQL or Postgresql connection.
#!/bin/bash
for i in `seq 1 ${CONNECT_TIMEOUT}`;
do
mysql -h "${DB_HOST}" -u${DB_USERNAME} -p${DB_PASSWORD} ${DB_DATABASE} -e 'select 1'
if [ $? -eq 0 ]; then
echo "Connected to MySQL"
exit 0
fi
if [ $i -eq ${CONNECT_TIMEOUT} ]; then
echo "MySQL timeout"
exit 1
fi
sleep 1
done
Fortune cookie: Today's spam: I wish she were here with me to see the gains I've put on - 3 full inches
Leave a Reply