BASH script to FTP a log file to another server monthly

I recently wrote a quick BASH shell script to FTP a log file to another server monthly. First, I modified the logrorate configuration to rotate a service’s logs monthly. Then I added a cron job to be executed the following script once a month. NOTE: It’s important to give logrotate enough time to finish rotating the logs. Here’s my script:

#!/bin/bash

_user="MYFTPUSER"
_password="MYFTPPASSWORD"

# create a date string in the format YYYYMM for last month
_date=$(date +%Y%m --date="-1 month")

# Create FTP connection and put the log in the user's home folder
ftp -n MYFTPSERVER <<EOF
user $_user $_password
binary
put /var/log/MYROTATEDLOG.log.1 ~/MYROTATEDLOG.$_date.log
bye
EOF

Updated: