crontab : /bin/sh : Syntax Error : Unterminated quoted string

crontab has limited environment setup as a result some commands which runs on shell prompt may not run on crontab. Also by default crontab uses /bin/sh as shell.
While adding a crontab entry to generate file with date in file name, I used date command as follows `date “+%m”` in the crontab file.

As it happens I got error
/bin/sh : Syntax error : Unterminated quoted string

after searching a lot, I got solution in one of the post of www(.)stackoverflow(.)com. ‘%’ is treated as a special character in crontab and it means ‘newline’, so one need to escape ‘%’ in crontab with \
* * * * * mkdir `date “+\%m”

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment