1👍
✅
You should use a job scheduler for such thing, you have multiple options with different features and complexity and your choice will depend on your requirements. Here is some examples:
Another option is to create management task and run it using a cron job.
Source:stackexchange.com