0

I have a website which stores and shows some data. This data is stored in a MySQL database. I basically have two different PHP scripts:

-One that collects and inserts/updates the data into the database.
-Other that shows the data for the users that visit the website.

I want to automatize the first script so it can collect and update the database data in intervals of time, for example each hour.

I haven't find any solution yet so what I do is executing that first script by myself typing in the url bar: wwww.mywebsite.es/folder/updatedata.php

I can't figure out a solution where the script isn't executed by an user.

Thanks.

EricLavault
  • 12,130
  • 3
  • 23
  • 45
DaftPunk
  • 13
  • 1

1 Answers1

0

You need to setup a cron job :

cron is a Linux utility which schedules a command or script on your server to run automatically at a specified time and date.

A cron job is the scheduled task itself. Cron jobs can be very useful to automate repetitive tasks.

http://man7.org/linux/man-pages/man5/crontab.5.html

See this question : How to create cron job using PHP?

There are some alternative to the classic cron :

  • fcron : Fcron is a periodical command scheduler which aims at replacing Vixie Cron and that makes no assumptions on whether your system is running all the time or regularly, it does not need your system to be up 7 days a week, 24 hours a day.
  • jobber : Utility for Unix-like systems that can run arbitrary commands, or “jobs”, according to a schedule. It is meant to be a better alternative to the classic Unix utility cron.
  • chronos : A fault tolerant job scheduler for Apache Mesos which handles dependencies and ISO8601 based schedules.
EricLavault
  • 12,130
  • 3
  • 23
  • 45