Hello, there was a problem with cleaning the data in the table. It takes something after some time to clear the old records, in my case it is 1 minute. Writing

<?php include_once 'setting.php'; $CONNECT = mysqli_connect(HOST, USER, PASS, DB); mysqli_query($CONNECT, "DELETE FROM `online` WHERE `time` < SUBTIME(NOW(), '0 0:01:0')"); ?> 

The time parameter in the online table has the following look: 2016-10-13 03:00:50

But he does not want to work (

Everything works, just in the main file the cron task is not involved. Thanks to everyone who took the time.

  • And so? DELETE FROM online WHERE datediff (minute, time , NOW ())> 1 - T.Zagidullin
  • It looks like the tool is not chosen correctly. redis with ttl (Time to live) or storage in memcache with ttl memory - better. delete - especially if not on an indexed field, a very expensive operation. - E_p

2 answers 2

For this task, you can simply use CRON (Task Scheduler). On the server, configure cron and set the server to call the file itself every minute (in which sql is located for deletion) and .. everything)) you can read here

     DELETE FROM `online` WHERE `time` < NOW() - INTERVAL 1 MINUTE; 
    • So also tried, does not help ( - Puvvl
    • checked on connection with a DB everything works. Why he doesn’t want to delete records ... - Puvvl