I'm trying to upload dynamically created log file from my local box to my FTP server. This all happens in a cron job (crontab) I run every night. It creates the file using:
30 00 * * * touch ~/Desktop/logs/"log$(date +'\%m\%d\%y')"
Which works just fine. However, when I try to upload the file using the same syntax:
50 00 * * * curl -T ~/Desktop/logs/"log$(date +'\%m\%d\&y')" -u user:pass ftp://example.com/logs/
It gives me the following error:
date: extra Operand
I also tried it without escaping the the %:
curl -T ~/Desktop/logs/"log$(date +'%m%d%y')" -u user:pass ftp://example.com/logs/
Which works in the normal command line, but when executed via the crontab, gives the following error:
/bin/sh: Syntax error: Unterminated quoted string
Any ideas how to successfully upload the daily log to my server?
%m%d%Y, use%Y-%m-%d! Or equivalentlydate -I. – poolie Oct 18 '11 at 22:05