It is a matter of escaping variables:
* * * * * /usr/bin/touch /tmp/$(date +\%Y:\%m).log
# ^ ^
worked to me.
From man 5 crontab
:
Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
So
*/25 * * * * /bin/bash script.sh > "/var/log/$(date +\%Y-\%m-\%d_\%H:\%M).log"
# ^ ^ ^ ^ ^
should work.
Note I used /bin/bash
instead of just bash
.