A breadcrumb for the internet: it turns out percent (%) signs get converted to newlines inside crontabs. This is one of those things that I probably learnt in the past but forgot until it bit me: it's useful if you need to send multi-line strings as input to a command in cron. From the manpage:
The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab file. Per‐cent-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.
If you have unescaped %'s you will likely see errors like this:
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file
No comments:
Post a Comment