Aims. The formation of high-mass stars is still debated. For this reason, several projects such as Herschel-HOBYS are focussed on the study of the earliest phases of massive star formation. As a result, massive star-forming complexes such as NGC 6334 and NGC 6357 have been observed in the far-infrared to study their massive dense cores where massive stars are expected to form. However, to better characterise the environments of these cores we need to understand the previous massive star formation history. To better characterise the environment of these massive dense cores we study the previous high-mass star formation and how these stars act on their environments. Methods. This study is based on the spectral classification of the OB stars identified towards NGC 6334 and NGC 6357 with spectra taken with the AAOmega spectrograph on the Anglo-Australian Telescope (AAT). From the subsequent spectral classification of 109 stars across these regions we were able to evaluate the following: distance, age, mass, global star-forming efficiency (SFE), and star formation rate (SFR) of the regions. The physical conditions of the ionised gas for both complexes was also derived. Results. We confirm that NGC 6334 and NGC 6357 belong to the Saggitarius-Carina arm which, in this direction, extends from 1 kpc to 2.2 kpc. From the location of the stars in Hertzprung-Russell diagram we show that stars older than ∼10 Myr are broadly spread across these complexes, while younger stars are mainly located in the H ii regions and stellar clusters. Our data also suggests that some of the young stars can be considered runaway stars. We evaluate a SFE of 0.019 +0.008 −0.007 and 0.021 +0.004 −0.003 and a SFR of 1.1 × 10 3 ± 300 M Myr −1 and 1.7 × 10 3 ± 400 M Myr −1 for NGC 6334 and NGC 6357, respectively. We note that 29 OB stars have X-ray counterparts, most of them belonging to NGC 6357. This suggests that molecular clouds in NGC 6357 are more impacted by X-ray flux and stellar winds than in NGC 6334. Finally, from the analysis of nebular lines (Hα, [NII], and [SII]) from spectra from several regions of ionised gas, we confirm that the filaments in NGC 6357 are shock heated.