I can see that this is "usual" error, but can not find solution in my case...
Running Crontab job with:
expr `date +%W` % 2 > /dev/null && curl https://mysite.com/myscript
It causes errors:
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file
Can you help me how to avoid them? Thank you very much in advance!
You have to escape the %
character. man 5 crontab
says:
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.
Try to escape %
AND don't use backticks to encose date
-command. Do enclose it with $()
:
expr $(date +\%W) % 2 > /dev/null && curl https://mysite.com/myscript
OR
expr $(date +\%W % 2) > /dev/null && curl https://mysite.com/myscript
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With