Powerful tools like logrotate make the work of rotating log or backup files much easier. This will rotate the files after a certain period of time or when they reach a certain size. If you don't have this tool available on a remote server and can only execute remote SSH commands, you can use a small bash script that deletes old files and only makes one request.
3c60340a9838f9759ee93711c14d34cf