I need shell script to delete all files older than 30 days from FTP server directories. I need to delete files from 5 different directories which are older than 30 days, should not delete the directories because they might have other files, have to delete only files older than 30 days. This is the first time I am working on shell script. tried following link no luck. can anyone help me on this.
FTP delete directories older than X days
below is the code I am using in my .sh file but I am facing invalid command error
ftp -inv $HOST <<EOS
user $ftp_user $ftp_pass
find /path/somefolder/ -type f -iname '*' -mtime +30 -exec rm {} \;
quit
EOS
Need to check if file is older than 30 days if it is older delete it from the directory.