I have a simple script to connect to a extern MySQL server.
#!/bin/bash
server=1.2.3.1
port=3306
user=root
pass=root
db=radius
output=$(mysql -N -h $server -u $user -p$pass $db -e "select * from table)
echo "$output"
The problem is when the mysql service fails on server 1.2.3.1, because the script gets stucked waiting for answer a long time!
How can I wait only for 1 second and if server doesn't respond, the script kills the process? Or how can I check if the service is up on the remote server before?
Regards.