How do you set a DATE variable to use in a log for crontab output?
Cron is not a shell - it does not parse commands in the same way that a shell does. As such, your variable is assigned as if it was static text.
There are three solutions I know of to this problem:
Option 1: Use a shell script to generate your command, include whatever variables and logic you want - and call that shell script from cron.
* * * * * /path/to/myscript.sh
myscript.sh:
DATEVAR=`date +20\%y\%m\%d_\%H\%M\%S`
echo $DATEVAR >> /tmp/crontab.log
Option 2: Include the date command directly in your command, and, since the entire command is passed to the shell, the date will be processed and replaced with an actual date.
* * * * * /bin/echo `date +20\%y\%m\%d_\%H\%M\%S` >> /tmp/crontab.log
Option 3: Set the string variable in cron, and pass that to your command to be processed (note - the percent signs do not need to be escaped, and the variable itself is wrapped in $() to execute it in a separate shell - backticks should work the same):
DATEVAR=date +20%y%m%d_%H%M%S
* * * * * /bin/echo $($DATEVAR) >> /tmp/crontab.log
(In all the cases above, you can, of course, use a variable for the log path, instead of 'hard coding' it.)