%-sign in crontabs

The %-sign has a special meaning in crontab.

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 don’t forget to escape the %-signs with a backslash if you use them for example to format the date output:

`date +'\%Y\%m\%d'`

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.