When to use a Contoller vs Middleware

Basically, I want to change the category of a post if it is older than 30 days without me having to go in and manually do it. Is the best way to do this through a controller?

Ex. Client requests posts, Contoller(?) checks posts, changes categories of ones that are older than 30 days (so they will not get called in this request ever again), and responds sending ones that are newer than 30 days old.