Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a PHP or MySQL script to do a task after time intervals [closed]

Tags:

php

mysql

How Can I write a PHP script or MySQL script to do a repetitive task after a period of time? One example of this could be to delete the top row of a specific table in the database every 120 seconds.

like image 485
Kshahnazari Avatar asked May 30 '26 10:05

Kshahnazari


1 Answers

Use EVENTS

CREATE EVENT delete_top_event
    ON SCHEDULE
      EVERY 2 MINUTE
    DO
      DELETE FROM your_table order by some_column desc limit 1;
like image 150
juergen d Avatar answered Jun 01 '26 00:06

juergen d



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!