Auto Schedule Program

I am trying to use php to automatically send birthday messages to my users using their birthday month and day from my database.
Now the problem am having is how to execute the the program even if I am not there to run it, That is to automatically check daily if today is a birthday of any of my users…
Please I need your help…

In Windows, use the Task Scheduler.

In Linux, use cron.

The command you tell the scheduler to run is the php interpreter, with the path to your file as its argument.

Ex: /usr/bin/php /path/to/your/website/filename.php

Hi tons613, welcome to the forums,

Talking PHP live site?

Uness you have CRON on your host, you can’t do anything like that at an exact time. But you can use what I call pseudo-cron to do it whenever a certain file is requested. For something like you want, this should be good enough. As long as you have enough site visitors to hit the file regularly and you don’t care if it runs at 12:00, 12:02, 12:25 etc.

For example you can store a “script last ran” value in a database table. Have your script check that value against the current time. If it’s a new day, run the script and update the db value, otherwise don’t run it.

Thanks a lot, I have tried using cron and it worked…

Just be sure not to run crons too often (I found that many new users configure cronjobs to be launched more often than needed due to lack of experience)