1

I have an application I am writing on Linux. It is a Java webapp intended to be run on Tomcat. When it initializes, my application will copy some standalone java utility programs to the host filesystem that it will shell out to over the course of its runs. Assume that it is not desireable for me to run these utilities in the Tomcat's JVM - they must be run in their own JVM as standalone Java apps.

The java utilities themselves will be ephemeral that do need to last between runs of my app (and I may upgrade over time), but the utilities do save data to the filesystem that does need to persist between runs (the folder where the utility's data is stored is configurable.)

I don't know or care where my Java webapp lives; the host's Tomcat will manage that for me. But, I would like to know where it is best (aesthetically, traditionally, for security reasons, etc) on Linux for me to write my utility programs and where it is best for me to direct those programs to write their persistent data.

Places I have thought about writing to are subfolders under the Tomcat user's home and under /var. Writing to /tmp scares me, I've seen that folder run out of space because its partition wasn't the main one. Do I write everything under one folder (ephemeral and persistent) or do I split everything up?

As you can probably tell, I know enough to be dangerous on Linux/Unix systems, but I don't know enough for software architecture. I'd hate for my app to do something awkward or non-traditional for Linux systems with the customer's filesystem.

  • 5
    Since you're a Java developer, you are probably not afraid of standards and specifications. The relevant specifications are the Filesystem Hierarchy Specification and the Linux Standard Base (which includes among lots of other things an extended version of the FHS). The LSB also specifies the behavior of Java apps on LSB-compliant systems as well as the APIs between Java and the OS, maybe you'll also find something there. The Free Desktop Group also publishes specifications on how to find the proper directories, but it is focused on destop apps. You still might be able to get some "feel" for … – Jörg W Mittag May 21 '17 at 15:01
  • 1
    … being a "proper" Linux citizen there. Lastly, you might get better answers on Unix & Linux, but please don't cross-post, if you decide to go that route; either delete this question or ask a moderator to migrate it for you. – Jörg W Mittag May 21 '17 at 15:02
  • 1
    Your hunch about /tmp is right: the definition of /tmp is basically: "an app should not care whether its files in /tmp get deleted at any time, even including while the app is running". – Jörg W Mittag May 21 '17 at 15:03
  • 2
    The app is "intended to be run on Tomcat", and your utilities are intended to be run by your app only. If I had a Tomcat instance to deploy your app, I would expect such files to be written in Tomcat's workDir directory, which is designed for that. I would think Linux standards are interesting but not necessarily relevant here, since those files are not meant to be shared with other stuff: it seems better to me to leave this to Tomcat, so a user (admin?) of your app would not need looking to too many places when using/managing your app... – Hugues M. May 21 '17 at 18:48
  • 1
    ... however if you intend to support other ways to deploy it, and Tomcat is just one of those, and all supported modes involve Linux, then yes, better look at the Linux standards. – Hugues M. May 21 '17 at 18:50

Your Answer

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

Browse other questions tagged or ask your own question.