  The flux of unstable secondary cosmic ray nuclei, produced by spallation
processes in the interstellar medium, can be used to constrain the residence
time of cosmic rays inside the Galaxy. Among them, $^{10}$Be is especially
useful because of its relatively long half-life of 1.39 Myr. In the framework
of the diffusive halo model we describe cosmic ray transport taking into
account all relevant interaction channels and accounting for the decay of
unstable secondary nuclei. We then compare our results with the data collected
by the Alpha Magnetic Spectrometer (AMS-02) on board the International Space
Station for the flux ratios Be/C, B/C, Be/O, B/O, C/O and Be/B as well as C, N
and O absolute fluxes. These measurements, and especially the Be/B ratio, allow
us to single out the flux of $^{10}$Be and infer a best fit propagation time of
CRs in the Galaxy. Our results show that, if the cross sections for the
production of secondary elements through spallation are taken at face value,
AMS-02 measurements are compatible with the standard picture based on CR
diffusion in a halo of size $H \gtrsim 5$ kpc. Taking into account the
uncertainties in the cross sections, this conclusion becomes less reliable,
although still compatible with the standard picture. Implications of our
findings for alternative models of CR transport are discussed.
