On CentOS 6, the Tomcat init.d script starts tomcat with this line:
$SU - $TOMCAT_USER -c "${TOMCAT_SCRIPT} start-security"
$ SU is either / bin / runuser or / bin / su, $ TOMCAT_USER is usually "tomcat", and $ TOMCAT_SCRIPT is usually "/ usr / sbin / tomcat6". "su -" or "runuser -" executes its command as the specified user from the specified user's home directory. Thus, this command will change to the user ID "tomcat" and the home directory, then run / usr / sbin / tomcat 6. Tomcat6 script will eventually run tomcat itself.
The tomcat user home directory should be the same as CATALINA_BASE. In short, the "su" or "runuser" command is what sets the current working directory to CATALINA_BASE.
init.d script is not an official part of tomcat; it is provided by a package supporter, and it may differ from system to system. On my Ubuntu 13 system, /etc/init.d/tomcat6 contains the cd for $ CATALINA_BASE.
Tomcat startup scripts (bin / startup.sh, etc.) do not set the working directory. When I launch tomcat 6 or tomcat 7 directly using my own script run, it just inherits the working directory from which I ran it.
Remember that on Linux you can see the current current directory of the process by checking /proc/<pid>/cwd .
source share