This was a very handy page as I have a requirement to DELETE records from a mySQL table where the expiry date is < Today.
I am on a shared host and CRON did not like the suggestion AndrewKDay. it also said (and I agree) that exposing the password in this way could be insecure.
I then tried turning Events ON in phpMyAdmin but again being on a shared host this was a no no. Sorry fancyPants.
So I turned to embedding the SQL script in a PHP file. I used the example [here][1]
[1]: https://www.w3schools.com/php/php_mysql_create_table.asp stored it in a sub folder somewhere safe and added an empty index.php for good measure. I was then able to test that this PHP file (and my SQL script) was working from the browser URL line.
All good so far. On to CRON. Following the above example almost worked. I ended up calling PHP before the path for my *.php file. Otherwise CRON didn't know what to do with the file.
my cron is set to run once per day and looks like this, modified for security.
00 * * * * php mywebsiteurl.com/wp-content/themes/ForteChildTheme/php/DeleteExpiredAssessment.php
For the final testing with CRON I initially set it to run each minute and had email alerts turned on. This quickly confirmed that it was running as planned and I changed it back to once per day.
Hope this helps.