I want to create a system-wide directory, that contains application specific (read-write) data (like log files, configurations and other app specific metadata).
After reading a bit more about the Linux file system, I thought about using /var/app_name/
, but then I found out, that some of the subdirs are temporary (not persistent among restarts, like run
, log
, tmp
).
How significant is this? I mean, should I use another directory (like /home/app_name/
) or using /var/app_name/
is OK?
Best Answer
From the Filesystem Hierarchy Standard:
You should use
/etc/app_name/
to store config files and other stuff for your program, and/var/log/app_name/
to store its logfiles.For the data used by the application, you can store:
/var/lib/app_name/
the persistent data and metadata/var/cache/app_name/
any app cache that can safely be deleted/var/spool/app_name/
the data that awaits processingDefinitely do not use
/home/app_name/
which is reserved to the homedir of user app_name. If your program needs to create a specific user to run as, that'll be its place.About your question in the comment: Linux does not delete neither rotate logs automatically for anything you put into
/var/log/
. In fact, often sysadmins have the opposite problem of logs filling up all the space... So it's up to you to delete or rotate logfiles; this is done vialogrotate
or a custom cron job.