A system is subject to shocks; each shock at time t increases the cumulative damage λ (t) by a constant amount, while the system is subject to repair in between the shocks which brings down λ (t) at a constant rate. The shock arrival process is an inhomogeneous Poisson process with intensity function λ (t) and each shock weakens the system making it more expensive to run. The long-run expected cost per unit time of running the system is obtained as well as the variance of the cost which are used to get optimal times of replacement of the system.