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.
mailcommand. Did you checked that cron run with the right permissions? – M'vy Jun 16 '11 at 8:15cronis running the job as root. – TheVillageIdiot Jun 16 '11 at 9:02crontab -llook like? – Kirk Jun 16 '11 at 12:22sudo crontab -l` . # m h dom mon dow command 0 22 * * * /usr/local/backups/osback.sh` – TheVillageIdiot Jun 16 '11 at 15:38