If you use Linux, use a cronjob.
Check if you have cron installed, perhaps using a man cron
or a sudo apt list --installed | grep cron
- it is usually installed in each linux distribution -, if not installed, install it with sudo apt install cron
.
Create a cronjob as follows:
crontab -e
and it will ask you to choose the text editor with which you want to write your cronjob.
After choosing your text editor, you will have to put the frequency of execution of your program followed by your program in the cron file, something like this:
* 18 * * * php /ruta/a/tu/programa.php
and "programa.php" will run every day at 6 o'clock in the afternoon of your time zone.
For more information about cronjobs see man 8 cron
, man 1 crontab
and / or man 5 crontab
Crontab allows you to execute tasks by frequency, something like this:
minutes hours days months dias_de_la_semana your_program
with the * * * * * program
format, that you can check in man 5 crontab
If you want help with the frequency, you can use this page: link