How to automatically delete old backups

I'm creating nightly backups using cygwin bash with this one line script:

zip -r "K:/backup/outlook/`date "+%y%m%d%M"`" C:/Documents\ and\ Settings/siegfried/Local\ Settings/Application\ Data/Microsoft/Outlook

How can I enhance my script using the "rm" command so I never have more than 4 zip files and the oldest is deleted?

I could use the cygwin bash "find" command to delete files older than four days, but this is not what I want (what if I miss doing backup one day or several days? I would not want to loose all my backups if I failed to do it regularly).

Also, is there any way to write a bash script that will kill the outlook process that locks these files? Hmmm... that may be more of a windows question that is more appropriate for a different forum...

Thanks,
Siegfried

Thanks,
siegfried

In Debian we have logrotate, which does the task of what you are speaking.

Is that is available in Cygwin ? or Any equivalent ?!

I believe there is such a utility and I looked into it previously. The problem was that it was specific to htpd.

How do I delete only the last line a a file? I suppos I could write a perl one-liner.

Assuming each log file name was a date, then I could call "ls | sort" and then how would I delete only the file whose file name that was last in the file?

Thanks,
siegfried