This paper suggests a numerical model of the Gleissberg cycle based on a spherical shell dynamo. The formulation of the problem includes a description both of the rotation law and of the hydromagnetic dynamo. The suggested model allows the Gleissberg cycle to be interpreted as resulting from the magnetic feedback on the angular momentum fluxes which maintain the rotation law in the shell. The period of the long-term variations is determined by relaxation properties of the shell. Hence, it is directly associated with the time taken to re-establish the differential rotation after the magnetic perturbations of the angular momentum transport.