0
I'm running Rasbian 3.12.26+ on a Pi model B.
Here is what my cron entry looks like:
* * * * * sleep 11; { echo -en "\e[1;4;33m"; date; echo -en "\e[0m"; curl -k "http://sampleurl.com/update.php"; } >> /var/log/cron/calls.log
Here is what my log looks like:
-en \e[1;4;33m
Thu Sep 4 14:29:13 UTC 2014
-en \e[0m
This is output from curl!
However, when I just paste the command into bash, it works as intended:
{ echo -en "\e[1;4;33m"; date; echo -en "\e[0m"; curl -k "http://sampleurl.com/update.php"; } >> /var/log/cron/calls.log
And the output is
Thu Sep 4 14:27:51 UTC 2014
This is output from curl!
With the first line underlined, bold and yellow as intended.
For some reason, when run by a crontab, the echo prints the "-en" instead of taking it as an argument. As a result, the color escape sequences do not get escaped.
What gives?
How can I change which shell crontab executes? – Nikita240 – 2014-09-04T14:50:36.213
add SHELL=/bin/bash on top of your cron – johnshen64 – 2014-09-04T14:53:08.463
Another way to get your escape sequences to produce color is to change
echo
(which the shell treats as a built-in command) to/bin/echo
(which is a separate program). (If that doesn't work, try/usr/bin/echo
.) – G-Man Says 'Reinstate Monica' – 2014-09-04T15:05:43.343