The following does work as expected:
date +\'%d-%b-%Y-%H-%M\' 28-Sep-2009-14-28
But none of the following 4 entries from crontab are working.
* *
There are four common causes for cron job commands to behave differently compared to commands typed directly into an interactive shell:
$PATH, and other expected variables missing./bin/sh by default, whereas you may be using some other shell interactively.% character specially (it is turned into a newline in the command).You must precede all % characters with a \ in a crontab file, which tells cron to just put a % in the command, e.g.
16 * * * * mysqldump myDB myTB > "/backup/ABCbc$(date +'\%d-\%b-\%Y-\%H-\%M').sql" 2> "/backup/ABCbc_errORS$(date +'\%d-\%b-\%Y-\%H-\%M').txt"
(As a separate matter, always put double quotes around a "$variable_substitution" or a "$(command substitution)", unless you know why not do it in a particular case. Otherwise, if the variable contents or command output contains whitespace or ?*\[, they will be interpreted by the shell.)