The solution from andrews-mark is fine: better to put commands inside a script and execute that script as cron job. This will avoid (almost) any problem with the cron environment and a lot of headache!
BTW, the problem you encountered is due to the special meaning of the % sign in crontabs. Putting a % in a crontab entry, means to start a newline. Indeed, the standard error from cron reports
Code:
/bin/sh: -c: line 0: unexpected EOF while looking for matching '`'
/bin/sh: -c: line 1: syntax error: unexpected end of file
As you can see, the command has been splitted into two lines. In line 0 bash cannot find the matching closing quote. In line 1 bash expects something more because encountered a starting quote. In other words, crontab represent the command as
Code:
/usr/BackupScriptsForCronjob/CCFullBackup.sh > /usr/BackupScriptsForCronjob/`date +
y%m%d-%a`-log.txt
Note that only the first % sign has the meaning of newline. I think (but not for sure) that the stuff after the first % is used as standard input from the previous command.
Now, let's see the workaround! To avoid this behaviour you have to simply escape every % sign with a backslash in front of it
Code:
0 1 * * 1-6 /usr/BackupScriptsForCronjob/CCFullBackup.sh > /usr/BackupScriptsForCronjob/`date +\%y\%m\%d-\%a`-log.txt
Sorry for the long preamble!