I run a script on a website each time the user will visit the homepage. The script will go through each rows in the database and check of its date has expired and archive it if true. However, since it has many rows, it does take some time (like 6 seconds) while loading the homepage.
Firstly, i suggested to use a cronjob for the task, but my boss suggested this idea, but i digress...
My question is, is it possible to run the script in parallel, so that, the homepage can continue on to load while the script is also running. Also note that the homepage displays data from the database, so it is quite important that the execution of the script ends before the homepage finishes loading