简体   繁体   English

更改日期和时间系统后,Tomcat冻结

[英]Tomcat freezes after changing date and time system

I'm working on a GWT application that has a feature to change system's date and time. 我正在使用具有更改系统日期和时间功能的GWT应用程序。 In order to execute the linux date command (for example: date 052810242012 ) the following line is executed but after that tomcat freezes: 为了执行linux date命令(例如: date 052810242012 ),执行了以下行,但是之后,tomcat冻结了:

Runtime.getRuntime().exec(this.command);  // where this.command is the date command 

I've realized that even if the application is up and running and I change the system date and time in a terminal, it freezes the application anyway. 我已经意识到,即使应用程序已启动并正在运行,并且在终端中更改系统日期和时间,它仍然会冻结应用程序。

Could someone explain why ? 有人可以解释为什么吗?

Firstly, I think the command that you wanted to execute is a root-only command,so you must make sure that the owner of your application is a sudoer,and it has right to execute that command. 首先,我认为您要执行的命令是仅根命令,因此您必须确保应用程序的所有者是sudoer,并且有权执行该命令。

Second, Runtime.getRuntime().exec() offers an interface to execute system command for JAVA but there is a difference between executing directly on the temina because it deals with the input and output itself, and will not print on the screen like teminal so you must deal with the result of the command in the JVM or write the command into a executable shell script with no output and call Runtime.getRuntime().exec(sudo","./a.sh"}; 其次, Runtime.getRuntime().exec()提供了一个接口来执行JAVA的系统命令,但是直接在temina上执行之间存在区别,因为它处理输入和输出本身,并且不会像teminal一样在屏幕上打印因此,您必须在JVM中处理命令的结果,或者将命令写入没有输出的可执行Shell脚本中,然后调用Runtime.getRuntime().exec(sudo","./a.sh"};

Finally, the problem you mention when you change the date and time in a teminal leads to freeze the application, I've never seen this before. 最后,您在更改终端中的日期和时间时提到的问题导致应用程序冻结,我以前从未见过。 Could you just explain its detail ? 您能解释一下它的细节吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM