Page 1 of 1
Cron job or not to Cron job it?
Posted: Thu Sep 05, 2013 9:48 pm
by cap2cap10
Greetings PHP Technorati. I hope all is well. I come to you seeking more guidance on the subject of using a cron job to delete a mysql field entry 15 minutes after the entry is entered by the user. I haven't done this before, but should I use some sort of time expiration php script or leave it to the mysql cron job to run every 15 minutes, deleting new entries? Any thoughts on this matter as always is greatly appreciated.
thanks in advance.
Batoe
.:To code or not to code is never the question!:.

Re: Cron job or not to Cron job it?
Posted: Thu Sep 05, 2013 11:47 pm
by Christopher
You can use a cron job to run a PHP script or use
MySQL Event Scheduler (if you have MySQL 5.1 or greater).
I would recommend running the delete job every minute, given what you described. That will make sure that no matter when the entry was created -- it will be delete 15 minutes later. If you run it every 15 minutes then records will be deleted between 15 and 30 minutes later.
Re: Cron job or not to Cron job it?
Posted: Thu Sep 05, 2013 11:55 pm
by requinix
Are you sure you have to completely delete it? Would it not be enough to make sure it's excluded from whatever searches once it's 15 minutes old?
Re: Cron job or not to Cron job it?
Posted: Fri Sep 06, 2013 11:19 am
by Christopher
True, you could timestamp records and have the code decide whether the data in question is available.
Re: Cron job or not to Cron job it?
Posted: Thu Jan 29, 2015 2:35 pm
by cap2cap10
Yes , the information is at best meant to be temporary for the user of the application. Hence, as a security measure, records are not to be backed up and must be deleted within a set time. Besides, how do you hack something that is not stored in the db long enough for you to get your hands on it?
Sun Tsu: Art of War- Eliminate your enemy's options.
Thanks again,
Batoe
