Escape percent signs in a cron command
A percent sign in a crontab command ends the command and feeds the rest to stdin. Escape it with a backslash, or the date call below breaks at once.
A cron job that works in a terminal fails every time it runs, and the only difference is date +%F in the command.
crontab - <<'EOF'
* * * * * date +%F > /tmp/bad.txt
* * * * * date +\%F > /tmp/good.txt
EOF
sleep 65
echo "bad:"; cat /tmp/bad.txt
echo "good:"; cat /tmp/good.txtbad:
cat: /tmp/bad.txt: No such file or directory
good:
2026-11-06In a crontab line an unescaped percent sign is turned into a newline, and everything after the first one is sent to the command as standard input, which is how the crontab format is specified. The shell therefore ran only date +, and the redirection text F > /tmp/bad.txt became its input, so the file was never even created. Escaping the sign with a backslash passes it through.
The escape is needed in the crontab itself only. The same command in a script file called from cron needs no escape, which is a reason to keep anything with a percent sign out of the crontab. Not every cron treats the percent sign alike, so check the manual of the implementation in use.