• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

mysql exit codes

Atheus

Diamond Member
This might be better off on a mysql dev forum, but you never know what valuable nuggets of genius might be extracted from AnandTech on any given day, so here goes...

I have a script which checks for the 'too many connections' error and restarts mysql if it finds it. Yes it's a hack, and yes I'm working on a permanent fix, but for now I really need this. Here's the script:

#!/bin/sh

dt=$(date)

mysqladmin ping > /dev/null
if [ "$?" = 1 ]
then
echo "[$dt] down!"
#/etc/init.d/mysqld restart
else
echo "[$dt] up"
fi

exit 0

As you can see I rely on mysqladmin giving an exit code of '1' when it encounters too many connections. This works on an older server with an older version of mysql, but on this new server it appears to return '0', regardless of too many connections.

Any ideas on a command I can run that will return '0' for a working mysql server and '1' for too many connections?

 
Back
Top