I'm kinda new to backend programming. I want to check an api for weather of couple of cities from another website every 6hour and save the data that I receive in a database. This should be done without any request from front end. Any idea how can I do that?
Asked
Active
Viewed 113 times
1
-
use cron for this type of tasks. – kup Jul 30 '21 at 16:39
-
1Look into cron jobs. You can set a schedule on the server, and it will run the requested script for you. – aynber Jul 30 '21 at 16:39
-
1Lots of people told you about cron jobs and that's an important topic to understand - but you specifically asked how to run code indefinitely. To answer your question, the set_time_limit() function lets you adjust (or remove) the maximum execution time. This can also be configured in your php.ini file. See: https://www.php.net/manual/en/function.set-time-limit.php Additionally, see https://www.php.net/manual/en/info.configuration.php#ini.max-execution-time You should know that PHP's default settings disable the maximum execution time when invoked from the command-line, including cron. – Max Jul 30 '21 at 17:29
1 Answers
1
use your server cron job It lets you set a path to a php script and let you choose at what time you want it to run.

iambro
- 11
- 2