Linux 在 Tomcat 中更改时区
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12112188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change Timezone in Tomcat
提问by Nyxynyx
How can I change the timezone in Tomcat? The timezone used by one of the webapps (Solr) is not right (compared to MySQL timestamps), and I think changing Tomcat's timezone will help. Thanks!
如何更改Tomcat中的时区?其中一个 webapps (Solr) 使用的时区不正确(与 MySQL 时间戳相比),我认为更改 Tomcat 的时区会有所帮助。谢谢!
采纳答案by stark
Unless tomcat has a personal TZ environment variable, then it uses /etc/localtime
which on my system is a copy of /usr/share/zoneinfo/America/New_York
.
除非 tomcat 有一个个人 TZ 环境变量,否则它/etc/localtime
在我的系统上使用哪个是/usr/share/zoneinfo/America/New_York
.
Tomcat's personal timezone would be specified in its startup script in a form like:
Tomcat 的个人时区将在其启动脚本中以如下形式指定:
-Duser.timezone=GMT
回答by Paige Cook
回答by Eric Wang
Here is what I add at beginning of catalina.sh
(after shabang) to change tomcat's timezone:
这是我在开头catalina.sh
(在 shabang 之后)添加的内容以更改 tomcat 的时区:
TOMCAT_TIMEZONE="-Duser.timezone=Europe/Budapest"
CATALINA_OPTS="$CATALINA_OPTS $TOMCAT_TIMEZONE"
And don't forget to restart tomcat to take effect.
并且不要忘记重启tomcat才能生效。
回答by novicef
As said Eric Wang you may use
正如 Eric Wang 所说,你可以使用
TOMCAT_TIMEZONE="-Duser.timezone=Europe/Budapest"
CATALINA_OPTS="$CATALINA_OPTS $TOMCAT_TIMEZONE"
but on CentOS server I didn't find catalina.sh, instead of that I added these variables to /etc/sysconfig/tomcat6, and that's works!
但是在 CentOS 服务器上,我没有找到 catalina.sh,而是将这些变量添加到 /etc/sysconfig/tomcat6 中,这很有效!