The k-out-of-n system is a system consisting of n independent components such that the system works if and only if at least k of these n components are successfully running. Each component of the system is subject to shocks which arrive according to a nonhomogeneous Poisson process. When a shock takes place, the component is either minimally repaired (type 1 failure) or lying idle (type 2 failure). Assume that the probability of type 1 failure or type 2 failure depends on age. First, we investigate a general age replacement policy for a k-out-of-n system that incorporates minimal repair, shortage and excess costs. Under such a policy, the system is replaced at age T or at the occurrence of the (n-k + 1)th idle component, whichever occurs first. Moreover, we consider another model; we assume that the system operates some successive projects without interruptions. The replacement could not be performed at age T. In this case, the system is replaced at the completion of the Nth project or at the occurrence of the (n-k + 1)th idle component, whichever occurs first. For each model, we develop the long term expected cost per unit time and theoretically present the corresponding optimum replacement schedule. Finally, we give a numerical example illustrating the models we proposed. The proposed models include more realistic factors and extend many existing models.