Basically what I need to do is to update a database every X days/hours/minutes/seconds (to be set). How can I let a PHP page execute regularly?
4 Answers
Use a CRON job.
If you are using a hosting service with cpanel there is an option to set and it can be quite straightforward.
Otherwise there are plenty of CRON tutorials on the interwebs.
Be sure that the permissions on your script are set correctly for it to be executed.

- 1,371
- 1
- 16
- 38
This feature is not provided by php, but by another program depending on your operating system (crontab in unix, scheduled tasks in windows).

- 4,238
- 1
- 23
- 34
-
-
type "crontab -e" on the commandline and edit the given text file (one line per job). Check out wikipedia or the man pages for help on the file formatting. – Calimero Dec 21 '13 at 22:32
-
1
your choices are cron (as everyone is mentioned) in unix, task scheduler in windows, or a header in your php to check a file to see if whatever you need to happen has been processed in the last X minutes / hours / days
but the php-option is a terrible idea if cron/task scheduler is at all possible.

- 424
- 4
- 14
You can have for instance an HTML page reloaded every 15 seconds like this:
<META HTTP-EQUIV="refresh" CONTENT="15">
but is certainly wise to do this via cron or corresponding system tools to schedule repeated a programs.

- 162
- 2
-
1
-
-
True, but a bit of common sense makes the real intent of the question clear - he meant script, not page. "update a database every X days/hours/minutes/seconds" – Steve Dec 22 '13 at 21:10