I have a script that is run by cron
to create backup of a MySQL database and some files. After creating a tar ball and encrypting it with openSSH
I have to put it on a remote ftp server. Following is the code for ftp part:
HOST='abcd.dyndns.biz'
USER='username'
PASSWD='password'
FILE='myBack-'${LOCAL_HOST}'-'${DATENAME}'.enc.tar.gz'
DIRNAME='/usr/local/backups/'
cd ${DIRNAME}
ftp -n ${HOST} <<END_SCRIPT
quote USER ${USER}
quote PASS ${PASSWD}
cd backup
lcd ${DIRNAME}
put ${FILE}
quit
END_SCRIPT
If i directly run the script from command line > sudo ./mybackup.sh
it runs smoothly and put the backup file on ftp, but when it is running from cron
it has never put the file on ftp though other pre-ftp and post-ftp (like consolidating log file and emailing outcome) steps work fine. I am not able to get anything from any log files also or to pinpoint the cause.
NOTE:- Our dyndns.biz ip does not change as we have paid plan.
mail
command. Did you checked that cron run with the right permissions?cron
is running the job as root.crontab -l
look like?sudo crontab -l
` . # m h dom mon dow command 0 22 * * * /usr/local/backups/osback.sh`