I want to remove the .tar.gz in that is 5 days old based on the iso date. Kinda like this? (iso date - 5 days = file to remove.tar.gz)
The reason i'm doing this is because the FIND command does not work in lftp and I need this type of equation to use the rm command. Thanks :)
TODAY=$(date --iso) # Today's date like YYYY-MM-DD
FILE="/home/$TODAY.tar.gz"
tar -zcf $TODAY.tar.gz /home/minecraft
$LFTP << EOF
open ${USERNAME}:${PASSWORD}@${SERVER}
set ssl:verify-certificate no
put $FILE $TODAY.tar.gz
cd ..
rm -rf ${what should I put here??}
bye
You could do this:
TODAY=$(date --iso)
FILE="/home/$TODAY.tar.gz"
TODELETE=$(date --iso --date="5 days ago")
FILETODELETE="/home/$TODELETE.tar.gz"
...
rm -f $FILETODELETE
A better way would be configuring logrotate on the server to do the work for you, if you can.