Run a command periodically