The timekeeping element in every modern clock is a harmonic oscillator, a physical object (resonator) that vibrates or oscillates repetitively at a precisely constant frequency.
In mechanical clocks, this is either a pendulum or a balance wheel.
In some early electronic clocks and watches such as the Accutron, it is a tuning fork.
In quartz clocks and watches, it is a quartz crystal.
In atomic clocks, it is the vibration of electrons in atoms as they emit microwaves.
In early mechanical clocks before 1657, it was a crude balance wheel or foliot which was not a harmonic oscillator because it lacked a balance spring
As a result they were very inaccurate, with errors of perhaps an hour a day.
The advantage of a harmonic oscillator over other forms of oscillator is that it employs resonance to vibrate at a precise natural resonant frequency or 'beat' dependent only on its physical characteristics, and resists vibrating at other rates
The possible precision achievable by a harmonic oscillator is measured by a parameter called its Q, or quality factor, which increases (other things being equal) with its resonant frequency. This is why there has been a long term trend toward higher frequency oscillators in clocks
Balance wheels and pendulums always include a means of adjusting the rate of the timepiece
Quartz timepieces sometimes include a rate screw that adjusts a capacitor for that purpose
Atomic clocks are primary standards, and their rate cannot be adjusted.
Synchronized or slave clocks
Some clocks rely for their accuracy on an external oscillator; that is, they are automatically synchronized to a more accurate clock:
Slave clocks, used in large institutions and schools from the 1860s to the 1970s, kept time with a pendulum, but were wired to a master clock in the building, and periodically received a signal to synchronize them with the master, often on the hour. Later versions without pendulums were triggered by a pulse from the master clock and certain sequences used to force rapid synchronization following a power failure.
Synchronous electric clocks don't have an internal oscillator, but rely on the 50 or 60 Hz oscillation of the AC power line, which is synchronized by the utility to a precision oscillator
This drives a synchronous motor in the clock which rotates once for every cycle of the line voltage, and drives the gear train.
Computer real time clocks keep time with a quartz crystal, but are periodically (usually weekly) synchronized over the internet to atomic clocks (UTC), using a system called Network Time Protocol.
Radio clocks keep time with a quartz crystal, but are periodically (often daily) synchronized to atomic clocks (UTC) with time signals from government radio stations like WWV, WWVB, CHU, DCF77 and the GPS system.
This has the dual function of keeping the oscillator running by giving it 'pushes' to replace the energy lost to friction, and converting its vibrations into a series of pulses that serve to measure the time.