Using the "-t" option of "ls" you can list files sorted by the (modification) time stamp.
Using the "-E" option of "ls" you can have all time stamps displayed in the same format.
e.g.
ls -tE | sed 1d | head -1 | nawk '{ print $6 }'
Will display the modification date, in yyyy-mm-dd format, of the file which was modified most recent.
Using some date calculation (see other threads) you can find out how many days ago this file was modified.
Once you know this offset you can add to it the number of days representingg the 2 months. You can take just 60 for the 2 months or calculate it exactly considering whether the 2 months before had 28, 29, 30 or 31 days.
Once you have a new offset you can use "find . -mtime +(newoffset)" to remove the files.
Today it is Feb 14, 2007
Suppose your most recent log file was created on Jan 28, 2007
with ls -tE ............ you can find the date 2007-01-28
Using date math you can find out 2007-01-28 is 17 days ago compared to today.
Add the 60 (or 61, 31 for dec and 30 for nov) days to 17 resulting in 77 (or 78).
An offset of 78 days from today backwards is Nov 28, 2006
Using find . -mtime +77 ............. you can delete all files last modified before Nov 28, 2006
This would remove all file 2 months older than Jan 28, 2007
I had done this but now I am working on date math to find out the 60 days ago dates it should delete as compared to the lateset file which was 2007-01-13, which means 13-october-2006... any ideas