I was thinking on using this query.
DELETE * FROM `tableName` WHERE `timestamp` NOT IN (SELECT * FROM tableName SORT BY `timestamp` DESC LIMIT 30)
the query will be used to keep the most recent 30 records which have a primary of key of the unix timestamp. I have alot of records but i will only keep the most recent 30.