In this article, I propose you some useful Unix commands relative to Tomcat.

Delete the Tomcat log without restart
It’s possible to empty the Tomcat log wihout restart it:

huo@myserver:/opt/tomcat/logs>ls -l Catalina.out
-rw-r--r-- 1 huoadmin huoadmin 12345898 2014-02-15 10:15 catalina.out

huo@myserver:/opt/tomcat/logs>echo "" > catalina.out
-rw-r--r-- 1 huoadmin huoadmin 1 2014-02-15 10:16 catalina.out

Restart Tomcat
First, it is necessary to do a sudo in order to run programs with the security privileges of superuser:

huo@myserver:/opt/tomcat>sudo su - huoadmin

…try to stop the server:

huo@myserver:/opt/tomcat>/etc/init.d/tomcat restart 
huo@myserver:/opt/tomcat>/etc/init.d/tomcat stop

….but if this command doesn’t done and returns an error : we must get the PID of process:

huo@myserver:/opt/tomcat>ps -ef | grep tomcat
huoadmin    15945   1  0 Nov13  00:26:45  /usr/java....

…so, it is necessary to stop the process linked to the Tomcat server:

huo@myserver:/opt/tomcat>kill -9 15945

…finally, ensure that the process has been killed:

huo@myserver:/opt/tomcat>ps -ef | grep tomcat
huoadmin   5871 5850 0  07:31   pts/4   00:00:00 grep  --color=auto tomcat

…to finish, we can restart the Tomcat server:

huo@myserver:/opt/tomcat>/etc/init.d/tomcat start

That’s all!!!