简体   繁体   中英

Time delay in Mysql command

I would like to execute a mysql command after 5 minutes after a click on the browser by the client.

Is there a way to achieve this in pure MYSQL ?

Is there a way to have a "queue system" as well ?

Execute 1 time : run in 5 minutes

Execute 2 times : run in 5 minutes after the 1 time

SELECT SLEEP(5), detail on http://mysqlresources.com/documentation/date-time/sleep .

Having said that you should handle it in your application rather that database. If you do it on database less connection could be made and application pool maybe exausted.

It would be preferable to seperate the things, to avoid timeouts and other nasty errors.

You could use cron, or similar, to schedule the execution of a PHP script, like this one:

*/5 * * * * wget -O /dev/null -o /dev/null example.com

Kindly borrowed from here .

It would be preferable to create a script that gets called by wget every 5 minutes, and create a table in MySQL for the queue, and add logic to the called script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM