In this paper the influence of large-scale decreasing and increasing gradients of the density of magnetized plasma on the relaxation process of a continuously injected relativistic electron beam with an energy of 660 keV (vb=0.9c) and a pitch-angle distribution is studied using particle-in-cell numerical simulations. It is found that for the selected parameters in the case of a smoothly decreasing gradient and in a homogeneous plasma the formation of spatially limited plasma oscillations of large amplitude occurs. In such cases, modulation instability develops and a long-wave longitudinal modulation of the ion density is formed. In addition, the large amplitude of plasma waves accelerates plasma electrons to energies on the order of the beam energy. In the case of increasing and sharply decreasing gradients, a significant decrease in the amplitude of plasma oscillations and the formation of a turbulent ion density spectrum are observed. The possibility of acceleration of beam electrons to energies more than 2 times higher than the initial energy of the beam particles is also demonstrated. This process takes place not only during beam propagation in growing plasma density, but also in homogeneous plasma due to interaction of beam particles with plasma oscillations of large amplitude.