Php scheduling runs function in 10 minutes

There is function A and function B

What I would like to do, after running function A, it started counting, after 10 minutes, it triggered function B (only once).

Note that during counting, function A can be started again, so that multiple counters can be scheduled to run function B.

After some research I found that something is causing the cron to work, but since I am using CPanel (based on Linux) it seems like it is a design for rework instead of a one-time job.

Also, if I use sleep()

with 10 minutes, the server will no doubt be busy and will have problems if the user leaves before 10 minutes

How to do it? I already wrote a program for function B. It just needs to run the url 10 minutes after starting function A.

http://my_domain.com/yoga/api/video/check_processed

Many thanks.

+3


source to share


1 answer


When function A is called, you must insert the timestamp into another database table.

You can also add another column in this table which will have (timestamp + 10 minutes).



Now create a say runCron () function that will detect the time difference of the columns and then when it is 10 minutes then it will execute function B. Set up a cron job that will call runCron every minute.

+1


source







All Articles