I have a PHP script on my website that downloads a huge file (10-15 Mb), processes it, and updates a database. This script should be run once every day to make sure that the database is updated to the latest version.
I wonder if I can spawn/intiate a background process when the first user visits the website... conceptual as showed below:
<?php
require_once("my_data_downloader_and_updater.php");
if (is_first_visit_today) {
// This function call will probably take a couple of minutes... and I don't want the user to notice the delay
download_and_update_data();
}
echo "Welcome to this website";
?>
Can I run download_and_update_data
as a separate process or parallel running function without delaying the response to the user? Or should I use any other techniques (e.g. schedule daily "ping events" to the website, that intiates the function above)