0

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.

Hmm
  • 105
  • 10
  • Your `find` command is one that would work in a bash script or on a command line, which you could get via `ssh`, but here are you using `ftp`, which is not going to provide you a shell. Do you need to work with `ftp` or could you use `ssh` instead? – joanis Jun 22 '20 at 21:00

1 Answers1

-1

Create a loop who checks every file and get the file creation date, if the file is older than 30 days delete this. If loop iterator is directory file count, check next path.

p1oXYZ
  • 84
  • 1
  • 7