How to execute a block of code every 24 hours on a server?

I want to receive certain data from a website every 24 hours. The code should run every 24 hours and update the MySQL database. How can I accomplish this without any custom events?

Later I will use the same data to find the total difference.

totalIncrement = currentData - previousData p>

While early Data is retrieved from the MySQl database, and current data is retrieved from an external website request.

I heard about cron on linux but never tried. Can any body just give a basic idea for this? or any reliable connection?

Maybe I want to do it like this:

First, create a PHP program / file that performs the fetch task. The second execution of this PHP file every 24 hours or so ...

+6
source share
3 answers

Open the shell.
(Stop the drilling service stop serving the service )
Use vi (or another editor) to edit the cron file, or type " crontab -e " to make changes.
After editing, press " ESC ". Then " : wq " to save and close.
(Start the service again the beginning of the service) )
Stopping and starting the service is not necessary if you use crontab -e.

Your script should now be running. Check the syntax here or here . To see the changes you have made, enter crontab -l .

Hope this helps.

+2
source

It is safe to ignore tips on starting and stopping the cron daemon when editing crontab (5). The crontab (1) utility notifies the cron daemon that the crontab (5) file must be re-read and the changes will immediately affect. The only reason you need to restart the cron daemon is to edit the crontab (5) file directly without the crontab (1) utility.

0
source

First you need to make a php file for this cron.php example

Therefore, whenever you click on this link www.yourdomain.com/crom.php, a script is executed

Now add this link to cron's work. To configure cron to work on your server, you can this php class

-3
source

Source: https://habr.com/ru/post/895472/


All Articles