Scalar-field cosmologies with a generalized harmonic potential and matter with energy density $$\rho _m$$
ρ
m
, pressure $$p_m$$
p
m
, and barotropic equation of state (EoS) $$p_m=(\gamma -1)\rho _m, \; \gamma \in [0,2]$$
p
m
=
(
γ
-
1
)
ρ
m
,
γ
∈
[
0
,
2
]
in Kantowski–Sachs (KS) and closed Friedmann–Lemaître–Robertson–Walker (FLRW) metrics are investigated. We use methods from non-linear dynamical systems theory and averaging theory considering a time-dependent perturbation function D. We define a regular dynamical system over a compact phase space, obtaining global results. That is, for KS metric the global late-time attractors of full and time-averaged systems are two anisotropic contracting solutions, which are non-flat locally rotationally symmetric (LRS) Kasner and Taub (flat LRS Kasner) for $$0\le \gamma \le 2$$
0
≤
γ
≤
2
, and flat FLRW matter-dominated universe if $$0\le \gamma \le \frac{2}{3}$$
0
≤
γ
≤
2
3
. For closed FLRW metric late-time attractors of full and averaged systems are a flat matter-dominated FLRW universe for $$0\le \gamma \le \frac{2}{3}$$
0
≤
γ
≤
2
3
as in KS and Einstein–de Sitter solution for $$0\le \gamma <1$$
0
≤
γ
<
1
. Therefore, a time-averaged system determines future asymptotics of the full system. Also, oscillations entering the system through Klein–Gordon (KG) equation can be controlled and smoothed out when D goes monotonically to zero, and incidentally for the whole D-range for KS and closed FLRW (if $$0\le \gamma < 1$$
0
≤
γ
<
1
) too. However, for $$\gamma \ge 1$$
γ
≥
1
closed FLRW solutions of the full system depart from the solutions of the averaged system as D is large. Our results are supported by numerical simulations.