During commissioning of the CEBM accelerator, correcting dispersion, momentum compaction and betatron beam envelopes was essential for robust operation. To speed the diagnostic process we developed a method which allows one to track and correct the machine optics on-line.The method is based on measuring the propagation of 30 Hz modulated betatron oscillations. The beam optics of the accelerator was altered to decrease lattice sensitivity at critical points and to simpli@ control of the betatron function match. The calculation of the Courant-Snyder invariant from signals of each pair of beam position monitors was used for a correction of the betatron functions. The experience of optics correction and the study of long and short term machine reproducibility obtained during 1996 and early 1997 are also discussed. With minor modifications this method can also be used for on-line optics measurement and correction in circular accelerators.