X-ray free-electron lasers (FELs) hold promising prospects for opening up opportunities for ultra-fast sciences at the atomic and molecular system. A precise knowledge of temporal information of FEL pulses is the central issue for experiments. Here we proposed and demonstrated an online diagnostic method to determine the FEL temporal profiles at the Shanghai Soft X-ray FEL facility. This robust method, designed for seeded FELs, allows researchers to acquire real-time longitudinal profiles of FEL pulses with a resolution better than 3 fs. Based on this method, for the first time, we can directly measure various properties of FEL pulses from two stages and correlations between them online. This helps us to further understand the physics and realize the lasing of a stable, nearly fully coherent soft X-ray FEL through a two-stage harmonic up-shift configuration. This method also provides an intuitive way for precise detection and control of the relative timing between electron beams and external optical lasers.