How do I routinely extract the thumbnail of the most recent post?

No need for a routine here – use the WordPress hook system to “attach” a function that will run when a post is published:

// https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post

function wpse_225371_post_published( $post_id, $post ) {
   // Do your thang
}

add_action( 'post_published', 'wpse_225371_post_published', 10, 2 );