to cleanup files older than X days is easy using the find command:
find /path/to/dir -mtime +X -delete
- use atime for last accessed time
- use ctime for created time
- use mtime for last modified time
Please BE CAREFUL when you run this command, it will not prompt you for permission to delete.