title: Automatically delete outdated rows from database every n seconds
body: <p>I have a database which has a timestamp column and I want outdated data to be deleted.</p>
  
  <p>So my idea is to write a MySQL query to a .php file which deletes every row where <code>timestamp &lt; current_timestamp - const</code>. As there will be a lot of rows where this has to be checked, I am going to set an index to the timestamp column.</p>
  
  <p>So how can I run this script automatically every n seconds? I heard about Linux crontab - can I use this on my webserver (not the db server) to execute the .php file periodically and is this overall a good technique to delete outdated rows from a database?</p>
  
  <p>The database is set on a RDS instance on Amazon Web Services. My webserver is a EC2 instance (also Amazon Web Services).</p>