RIck's expression is the best solution. If you own the extension iExpressions, you don't need to write your own expressions code and can use this iExpression instead:
If you want to animate the image you uploaded you have to have each gear on a separate layer. You have to count the number of teeth on each gear, figure out the ratio between the number of teeth, then rotate the driven gear in the opposite direction as the drive gear using that ratio. If you make your gears using a shape layer the expression would look like this:
The Drv variable is the number of teeth on the gear that is driving the other gear - the Drive Gear layer.
The shisGR variable is the number of teeth on the gear on this layer. The anchor points must be in the center of each gear.
If the gears do not mesh properly, and only a few of the gears in your image do mesh, then you have to use the diameter and live with gears that don't mesh.
This needs some testing, but I imagine that gears that touch each other should have reversed direction in rotation, that's why I would animate the central one (big red gear) using an expression as Byron said, then I would select all the gears around it and apply a negative expression (e.g: -time*100), then select the next level of gears applying the original expression, and so on. Of course, mathematically this is wrong because speed depends on the radius, but if visually the animation looked correct you can get away with that, otherwise, you should use an expression that depends on the radius
If you want to rotate the gears that you see are not meshed, you must use the simple Expression "time".For example time*100 where 100 is the degree of turns per second, if you want it to turn a full turn in 1 second you must put time*360. If you want them to rotate to the left you must write time*-360.