I'm hosting quite a few servers, for customers and for our own usage. All these servers run Debian Stable. All of the servers are virtual servers. This is for the eventuality that an automatic update will kill one of the machines: Just replace it with the snapshot from last night, and everything will be peachy again.

Now, some of these servers run Tomcat applications. One of these Tomcat applications requires more memory than the default Tomcat allocation. So far, I've preferred to add the memory allocation to /etc/init.d/tomcat7, however, we also had servers where it was in the catalina.sh directly.

After having the problem that a Tomcat stopped today, we found that the memory allocations were suddenly gone. We thought of the configured automatic updates, and indeed, cron-apt log files showed that at the end of april, there was a tomcat update. So we think that this update most probably will have overwritten both files.

Now Tomcat is run under the user tomcat7 (and the group tomcat7 as well). The user has /usr/share/tomcat7 as a home and has no interactive shell to better place the memory allocations in).

Where would be the correct place to export the JAVA_OPTS variable for the tomcat7 user to set the memory while still being update-proof?


Usually JAVA_OPTS should be in setenv.sh located in the tomcat bin you should find it in /usr/share/tomcat7/ (the CATALINA_HOME).

If this file is missing you can create it (/usr/share/tomcat7/bin/setenv.sh) and set +x bit.

Just put this in the empty file: JAVA_OPTS="$JAVA_OPTS <your params>"

That file won't be overwritten by updates.

Note: Remove $JAVA_OPTS if you want to fully overwrite any previous value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.