For one reason or another at random times, my webhost reboots the sever that hosts my CentOS VPS, when this happens it often causes one of my MySQL tables to crash. The table handles the sites PHP sessions (a Joomla site powered by PHP).
The site gets a fair amount of traffic so when the VPS is rebooted, the session table is often being written to.
Is there anything I can do to stop this happening? Perhaps some sort of soft MySQL shutdown when the server gets the reboot command?
The only thing I am doing now is auto repairing the table when the server comes back up.
Change webhost, if you are renting a VPS there should be no reason your host would be randomly rebooting your server. Normally when a system halt is called, MySQL shuts down properly. I suspect your provider just gives a kill command rather than a proper shutdown.
You could switch to InnoDB tables on your database, or use a database system that supports full ACID-compliant transactions; PostgreSQL does that and can crash without clobbering your database (it just has to replay its journal before it finishes its startup process).
MySQL's default tables are not crash-safe. I'm not even sure that I would call InnoDB crash safe, but it's as close as you're going to realistically get without switching to another product, and I assume that is not an option for you.
Are you using the MySQL package that CentOS ships? If you are, the mysqld should be shut down via the /etc/init.d/mysqld script. What does the following command return?
If it's "off" for each runlevel, try running