INT 21h

Hi, I am Vladimir Smagin, SysAdmin and Kaptain. Telegram Email / GIT / Thingiverse / RSS / GPG

bash: wait database for connection

№ 10430 В разделе "Sysadmin" от December 6th, 2019,
В подшивках: , ,

You can easily use it to check MySQL or Postgresql connection.


for i in `seq 1 ${CONNECT_TIMEOUT}`;
  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
  if [ $i -eq ${CONNECT_TIMEOUT} ]; then
    echo "MySQL timeout"
    exit 1
  sleep 1

Нет комментариев »

Leave a Reply

Your email address will not be published. Required fields are marked *



Fortune cookie: Mr and Mrs PED, can I borrow 26.7% of the RAYON TEXTILE production of the INDONESIAN archipelago?