To your question, there are many ways to do it:
- Cron job (external to your app)
- In-app (server side) job (
new EvTimer()
in php, setInterval()
in node/js, javax.swing.Timer
in Java, ETC.)
- Thread + sleep (please don't do that)
- Alarm signal (you should probably not)
But instead of deleting on an interval and relying on it, I suggest the below, it will also give you correctness of exact 24h (you might not require it, but it is good anyway):
- your records need to be timestamped (almost every solution
will require this)
- when you read the records, filter out records that the timestamp is
less than now minus 24 hours
- delete the old records (cleanup) on an interval, say once a day, using cron job oe in-app job.