Astronomical telescopes observe particular points in the sky for hours or even days, and they have to remain particularly steady for the duration of the observation, as far as I know. What happens when an earthquake shakes the ground? Does it ruin the observation? If so, how frequently does that happen?
Earthquakes are not uncommon in Hawaii and Chile, where several observatories are built. I only have personal experience with the observatory in La Silla, where a minor earthquake once occurred while I was observing. This was an old telescope, and the image was ruined. Modern telescopes may be able to withstand small seismic activities, but since we felt the ground shaking, I think the image would've been ruined on any telescope.
Luckily, images are not taken in one, long exposure. Rather, they're composed of multiple exposures that are added subsequently. You typically don't expose for more than 30 minutes. A faint object that requires, say, 5 hours of exposure, is then given by the median of 10 half-hour exposures. Why the median and not the mean? Although earthquakes are, after all, rare, cosmic rays quite often ruin a small region on the image, but when you take the median, such outliers are removed$^\dagger \!\!\!$.
In other words, the whole night isn't ruined, only the one exposure that was taken when the earthquake occurred.
Of greater concern are more violent earthquakes, which may in principle damage the telescope. Modern telescopes are prepared to deal with such seismic activity. For instance,
…ESO's VLT has a complex mechanical system that is automatically activated when it experiences a strong earthquake of magnitude 7 or higher. There are a series of clamps around the edges of the mirror, which can — at a moment's notice — lift the entire 23-tonne mirror off the actuators and secure it to the telescope’s support structure.
In 2006, an earthquake close to Hawaii shifted slightly the position of various things on the Subaru telescope, apparently resulting in people there working with pre- and post-2006 numbers, according to former telescope operator Dan Birchall.
Source: ESO, where you can also find more about how to prevent damage in case of earthquakes.
$^\dagger$For instance, if the values in a given pixel of 10 images are $[21,25,22,19,22,27,23,65536,18,24]$, then obviously something went wrong in the 8th exposure, and the median $(22.5)$ is more characteristic of the "true" value than the mean $(6573.7)$.