Google searching is your friend. I did a search on: google script clear a range of data
Here is a link that I found: https://www.youtube.com/watch?v=LiKF6Vq3P-s
Then one on: google script running a function periodically
This came up at the top of the list: https://stackoverflow.com/questions/3018875/is-it-possible-to-automate-google-spreadsheets-scripts-e-g-without-an-event-to
There are many other hits if neither of these fits what you want to do but as you read through the ones that don’t work you’ll learn so it’s not a loss.