Take action after reboot

All,

My VPS provider is not the most reliable. The actual server is rebooted far more often than one would expect. The problem with this is that when the server goes down, the file /var/lib/mysql/mysql.sock does not get deleted, so after reboot, mysql does not start because it cannot access the socket.

Fixing the problem is easy - simply delete the file and start mysql. What is hard is knowing when to do this.

So, with the preliminaries out of the way, how can I run a shell script shortly after the system reboots?

Howdy,

We’ve heard a few cases of what you’re describing occurring. The trick there is that you’d actually need to fix that fairly early on in the boot process, as it needs to happen before it tries to launch MySQL.

One way to do that would be to edit the MySQL init script, found in /etc/init.d/, and in there add the command to delete the .sock file.

-Eric

Eric,

Thanks for the reply. I am looking at the script file and per your suggestion, the appropriate course of actions seems to be the following:

In the start() function, after the check is made to see if mysql is already running - if it is not running and the .sock file exists, then delete the .sock file.

Seem about right?

Yup, that sounds perfect!

-Eric