you can get the oldest file in a directory like this:
Code:
/bin/ls -t | tail -n 1
among dozens of other ways, that's what springs to mind for me.
in practise i'd probably take a different approach and use a datestamp to implictly overwrite it. if you write to a file called
Code:
image`date +%I%M`.png
then that will include a 12 hour clock in the filename. so every 12 hours that file will be over written. I presume 20 is actually an arbitrary figure?