Ubuntu – How to delete files on a server doesn’t support SSH. Only sFTP

sftpUbuntu

So I can do this:
sftp user@server

These are the files
https://gist.github.com/438a6b82aff3064a19c9

i need to delete files older than 60 days.

Any way to automate this?

find command doesn't work.
deleting by wildcard doesn't work.

Rsync is supported. How is it done with rsync?

Best Answer

As an alternative to the better options above you could script (using lftp or something) to delete all files using a wildcard and a local date substiatution.

It's very ugly but it works:

for i in 60 999; do lftp sftp://user@host -c "rm /path/to/website_production_$(date -d "$i days ago" +%m-%d-%Y)*" done

You might want to set it up so you don't have to enter the password.