简体   繁体   中英

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. In order to execute the linux date command (for example: date 052810242012 ) the following line is executed but after that tomcat freezes:

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.

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"};

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 ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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