Optimal scheduling in a periodic environment