WooCommerce , Auto cancel orders status from processing after X days

Trying to use this code in function.php, but not working.. Any idea whats wrong?