How do I get colored output to a file from a bash script running in crontab?

不问归期 提交于 2019-12-06 10:29:35

Your cron environment almost certainly is just not specifying a terminal type that supports colors and so tput is not returning anything.

Compare:

$ echo $TERM
xterm-256color
$ printf %q\\n "$(tput setaf 5)"
$'\E[35m'
$ printf %q\\n "$(TERM=dumb tput setaf 5)"
''

I put TERM=xterm export TERM in the bash_profile file and the colors are working.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!