cron error: EOF in backquote substitution

Last night I got an error e-mail from my server when it tried to index the indieweb chat logs:

Subject: Cron ./bin/process.php`date +

/bin/sh: 1: Syntax error: EOF in backquote substitution

The actual crontab entry was:

#pinde indiechat
15 * * * *   cd /path && ./bin/process.php`date +%Y-%m-%d`

So what's up with that EOF (end of file) in there?

It turns out that in crontab files % has a special meaning:

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.

man 5 crontab

Simply adding a backslash before each percent sign fixed it:

#pinde indiechat
15 * * * *   cd /path && ./bin/process.php`date +\%Y-\%m-\%d`

Written by Christian Weiske.

Comments? Please send an e-mail.