I think that a cron job on the server(s) to delete files based on the file modification date would be a better solution.
You could use the find command to match the date and pattern both:
find /path/to/logs/ -name "logfile-*" -ctime -1 -exec dir rm '{}' \;
Note: there is an option of find to align -ctime to midnight, but I'm too lazy to look it up.
Otherwise, since cron will be performed daily, you can use yesterdays date to construct a wildcard to use in the ftp script.
You could then use something like JimMcNamara's script:
Code:
YESTERDAY=$(date --date=yesterday +%y%m%d)
SERVERNODE=<ip-address>
ftp user:password@${SERVERNODE} << EOF
cd logs/
del log-${YESTERDAY}
bye
EOF >localcleaninglog-$(date +%y%m%d)
I've used the form "ftp user:password@ipaddress <ftpscript"
in a loop to automate the renaming of files in a large number of devices (5 racks of duets) after we found out that we needed
to change all of the filenames to include leading zeros. It worked from my laptop running linux, but didn't work in windows
or using cygwin in windows. Also, the --date=yesterday is a GNU option of date.