I run my Web sites on a dedicated virtual server and every once in a while, I need to go in and optimize things to make sure everything runs smoothly. I am not an expert when it comes to shell commands, but do I know a few that really help keep things working the way they should.
One of the most important things I have come to realize is that you must keep an eye on your MySQL tables, because a problematic database can slow down your server dramatically. Databases that see a lot of queries often become fragmented and these are the databases that can start to cause you some problems. Luckily, there is a shell command that can go in and do all your de-fragmenting and optimizing for you.
I always make sure to back things up before I run this, just in case.
This command must be run from the shell and you need to be logged in as a root user:
mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
Once the command has been entered, you will need to input your password. Then you will see it list through your database tables one by one as it works it magic.
You can read up on the mysqlcheck command to understand exactly what it does.
Another worthwhile tool is MySQLTuner. It can help you with recommendations on how to configure your MySQL to increase performance and stability. I use it every month too see if anything has been acting up and that is a good routine to get into to keep your sites running their best.