from worst to best
...previously, microswitches were used, and they're not as long-lived.
Currently, reed switches (glass capsule with two magnetic-sensitive reeds) are commonly used especially in C-band dish movers.
Reed switches are also what they use at the top of door frames, with a magnet on the door, to sense when someone goes in or out of a business.
Hall effect sensors have the longest life, with no moving parts.
They are also the little black transistor-like device buried in the electronics of fan motors, located in your computer.
They detect the rotation of the fan, and control the electronics to energize coils to cause the fan to spin.
The fan blade has a magnet on it.
Another non-contact, and wear-free sensor, is the optical switch.
It typically consists of a light-emitting-diode and a light-sensitive-transistor.
While it has no moving parts, should the light path become clogged with dirt, the unit will stop operating.
The Hall Effect sensor is a better choice for industrial applications, since there is little that will stop the magnetic field that it senses.
Things like grease, dirt, mud, or bugs will not affect the Hall sensor.