Hi,
I have this small script:
Code:
#!/bin/bash
sfile=/tmp/.corrupted_table
TO_MAIL=xxx@gmail.com
if [ -f "${sfile}" ]; then
old_count=`cat /tmp/.corrupted_table`
else
old_count=0
fi
new_count=`/bin/grep -c "Got error" /var/lib/mysql/monster.evdaimon.com.err`
echo $new_count > $sfile
if [ "${new_count}" -ne "0" ] && [ "${old_count}" -ne "${new_count}" ]; then
mysqlcheck -Ar
echo "corrupted table found - issued repair" | mail -s "Corrupted table" $TO_MAIL
fi
exit 0
which will run under a cron.
I am unsure if mysqlcheck -Ar will run correctly. The rest will and already tested.
Anyone can verify/comment ?
Thanks