  Recent experiments have implemented resetting by means of an external trap,
whereby a system relaxes to the minimum of the trap and is reset in a finite
time. In this work, we set up and analyse the thermodynamics of such a
protocol. We present a general framework, even valid for non-Poissonian
resetting, that captures the thermodynamic work required to maintain a
resetting process up to a given observation time, and exactly calculate the
moment generating function of this work. Our framework is valid for a wide
range of systems, the only assumption being relaxation to equilibrium in the
resetting trap. Examples and extensions are considered. In the case of Brownian
motion, we investigate optimal resetting schemes that minimise work and its
fluctuations, the mean work for arbitrary switching protocols and comparisons
to previously studied resetting schemes. Numerical simulations are performed to
validate our findings.
