When an earthquake strikes, the shaking doesn't start instantaneously. Instead, the most violent energy spreads out from the epicenter at a relatively modest 3.5 kilometers per second. So-called earthquake early warning systems use a specially designed network of seismic stations to detect the shaking closest to the epicenter and send an alert out to people at more distant locations.
In this video of a simulation conducted by the United States Geological Survey we see how a magnitude 7.0 earthquake on the Hayward Fault in California would spread throughout the eastern half of the San Francisco Bay Area. The video runs in real-time. (Note that the ground deformation in the right panel has been magnified by 1,000 times.) In this particular scenario we see that the strongest shaking does not arrive in Livermore, about 70 kilometers southeast of the epicenter, until 50 seconds after the earthquake begins. Even with a delay for detection and processing, an earthquake early warning system would give power plants, construction sites and schools well over 30 seconds of warning time.