Automatically restart Tomcat and restart after the garbled problem
Tomcat as an open source server, performance and stability than some of the business Server or worse. When you deploy a project to Tomcat, it will die in the interval, and the main reason for this problem may be memory data overflow, because the Tomcat container is prone to problems when there is a large number of queries or operations with the database. Timed restart is a good remedy, and timed reboots can also reduce the risk of tomcat running, keeping the best performance of Tomcat.
The scheduled execution of the command is crontab, edit/var/spool/cron/under the root file (path depending on the system may be different, no root file on the new), add the following two lines:
1 6 * * */usr/local/apache-tomcat-6.0.20/bin/shutdown.sh
2 6 * * */usr/local/apache-tomcat-6.0.20/bin/startup.sh
The beginning of the 1 6 * * * indicated at the 6:1 A.M. daily Implementation, detailed introduction please Baidu.
This allows Tomcat to be turned on after 1 minutes of closure.
You may ask, can all be done at 6:1, which is written 1 6 * *? The answer is no, although the command to open Tomcat is written down below, the command at the same time is not executed sequentially, it is possible to execute the command that was turned on, and then execute the closed command so that Tomcat does not use it today.
Of course you can write these two lines (remove the previous 1 6 * * *) in a restarttomcat.sh file, add a line to sleep 10s in the middle, and then add a 1 6 * * * restarttomcat.sh to the root file. This will automatically restart Tomcat 6:1 A.M. every day.
The problem of automatic restart is solved, but it brings a new problem: The website is running well, but in some places the Chinese characters are garbled, and there is no garbled after the manual restart of Tomcat. The reason is that manual restart is not the same as the character set that is automatically restarted by the default system task. The solution is to edit the/usr/local/apache-tomcat-6.0.20/bin/catalina.sh and add a line to it:
Catalina_opts=-dfile.encoding=utf8
OK (the specific encoding is modified according to the page code).
The above is an article found on the Internet
I also encountered this problem in the automatic restart resin, modify the bin/httpd.sh file, plus the following code:
Lang= "en_US. UTF-8 "
Export LANG