外部调用Tomcat启动脚本后日志中文显示乱码问题的解决

外部sh脚本如下

 1 #!/bin/bash
 2 
 3 while read LINE
 4     do
 5     echo "Hello $LINE!"
 6     case $LINE in
 7     all)
 8     tail -f -n200 /smapp/servers/tomcat/apache-tomcat-7.0.96/logs/catalina.out &
 9     ;;
10     start)
11     /bin/bash /smapp/servers/tomcat/apache-tomcat-7.0.96/bin/startup.sh
12     ;;
13     stop)
14     /bin/bash /smapp/servers/tomcat/apache-tomcat-7.0.96/bin/shutdown.sh
15     ;;
16     *)
17     tail -f -n200 /smapp/servers/tomcat/apache-tomcat-7.0.96/logs/catalina.out | grep $LINE &
18     ;;
19     esac
20 done

输入时start时将回启动Tomcat,启动时启动了都是打印的中文成了乱码

网上找了下资料,解决方案如下

找打Tomcat的bin目录

打开catalina.sh

这里加一个 -Dfile.encoding=UTF-8

 

 再调用脚本

打印的中文恢复正常

 

posted on 2019-12-10 10:56  隔壁小老王  阅读(494)  评论(0编辑  收藏  举报

导航