Delete MySQL Row after 30 minutes using Cron Jobs/Event Scheduler

后端 未结 1 1412
渐次进展
渐次进展 2021-01-28 04:38

I am quite the noob at MySQL and PHP/Cron Jobs so if you all could explain it easily as in where to put the event, etc, that\'d be great, anyways, on with the question.

相关标签:
1条回答
  • 2021-01-28 05:23

    The SQL would be

    DELETE FROM my_table
    WHERE timestamp < NOW() - INTERVAL 30 MINUTE
    

    Write a PHP script that executes this SQL, and add a crontab entry that runs it every 30 minutes. Or use the MySQL Event Scheduler to run it periodically; it is described here.

    0 讨论(0)
提交回复
热议问题