Skip to content

Instantly share code, notes, and snippets.

@benoitjpnet
Created July 9, 2014 09:38
Show Gist options
  • Save benoitjpnet/519fcb26e8a9c2fadb31 to your computer and use it in GitHub Desktop.
Save benoitjpnet/519fcb26e8a9c2fadb31 to your computer and use it in GitHub Desktop.
Check for crashed MySQL table in syslog and launch a repair.
#!/bin/bash
tables=$(grep crashed /var/log/syslog | grep -Eo \'\./.*\' --color=auto | sed s#\'./## | sed s#\'## | uniq | tr -s '\n' ' ')
for tableC in $tables; do
db=${tableC%/*}
table=${tableC#*/}
mysqlcheck --auto-repair --check $db $table
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment