Operating System - HP-UX
1820553 Members
3542 Online
109626 Solutions
New Discussion юеВ

Re: Files and directories in /tmp and /var/tmp and their importance for system functionality

 
SOLVED
Go to solution

Files and directories in /tmp and /var/tmp and their importance for system functionality

Dear Gurus

I have a very fundamental question.

Why are there two seperate directories /tmp and /var/tmp in HP-UX?

what is the difference and the importance of these two directories?

How important are the files and directories in these directories for the working of the HP-UX OS (11iv1, 11iv2 and especially 11iv3 if there are any chnages)

Is it a normal system maintenance activity that these directories (both /tmp and /var/tmp are cleaned off? (including the directories and the files in these directories)

Is it ok for applications to depend heavily on these applications (stack not coming up if these files/directories in /var/tmp and /tmp are cleaned up, etc...)

What would be the very good way to warn end users not to delete any files or directories in these directories(through login banners or any other means)

Thank you very much for your time and patience.

Kind Regards,
Satya
Patience pays....but you will need pateince for that........
6 REPLIES 6
James R. Ferguson
Acclaimed Contributor
Solution

Re: Files and directories in /tmp and /var/tmp and their importance for system functionality

Hi:

> Why are there two seperate directories /tmp and /var/tmp in HP-UX?

The '/tmp' directory is intended to be reserved for use by system processes, while the /var/tmp' directory is targeted to _application_ use.

> How important are the files and directories in these directories for the working of the HP-UX OS (11iv1, 11iv2 and especially 11iv3 if there are any chnages)

Well, the directory's are expected to be present; particularly '/tmp'.

> Is it a normal system maintenance activity that these directories (both /tmp and /var/tmp are cleaned off? (including the directories and the files in these directories)

You can optionally cleanup these directories during startup by configuring '/etc/rc.config.d/clean_tmps'.

> Is it ok for applications to depend heavily on these applications (stack not coming up if these files/directories in /var/tmp and /tmp are cleaned up, etc...)

Cleaning up the directories at startup avoids problems, though you may not want to do this if you place patch depots in '/tmp' and expect them to be present for any period.

> What would be the very good way to warn end users not to delete any files or directories in these directories(through login banners or any other means)

I wouldn't expect users to read any banners, etc. Humans have a great capacity to ignore the familiar. Instead, you can set the "sticky bit" on the directories. Setting this bit means that only the owner of a file in the directory has the right to remove it.

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: Files and directories in /tmp and /var/tmp and their importance for system functionality

As mentioned, /tmp and /var/tmp are important since so many processes will create and use files in those directories. But you can't remove files arbitrarily as programs my be using the files. There is no easy way to identify usage without understanding what programs created the file(s) and why. The simplest way to manage the space is to enable the clean tempfile script in /sbin/init.d/ and then schedule a regular reboot every few weeks.


Bill Hassell, sysadmin
Suraj K Sankari
Honored Contributor

Re: Files and directories in /tmp and /var/tmp and their importance for system functionality

Hi,

If you need to store large files on a temporary basis and don't have enough room in your quota for them, you might consider using /var/tmp and /tmp on the shell hosts. These directories are available to you and the data stored there does not count against your quota.

Here's what you need to know about /var/tmp and /tmp:


/var/tmp and /tmp are shared space, and are used by numerous commands as a matter of course. It is your responsibility to make sure that your use of the space does not interfere with others' responsible use of the system.


Unlike unlike your home and web directories, /tmp and /var/tmp are separate and discrete across the Panix userhosts. So, if you put a file into /tmp on panix1, it will not be accessible on panix2, panix3, or panix5.


Files in /tmp and /var/tmp are removed after 30 days, regardless. If you need to keep a large file for longer than that, you should make arrangements to purchase more disk space.


There are differences between /var/tmp and /tmp:
The basic difference is that anything in /tmp is deleted when the machine reboots. (This is rare, but both scheduled and unscheduled reboots happen, so if you need short-term survival of a file, put it in /var/tmp.

Notwithstanding, files in /var/tmp on a particular machine might be destroyed if there is a hardware failure, system upgrade, observation by staff that we're low in space in /var/tmp on a particular box, or any other maintenance. (Again, this is rare, but it means that you cannot count on files stored in /var/tmp either.


/var/tmp and /tmp are not necessarily the same size on the different machines, and are likely to have different amounts of space available (depending on what other users have stored there). Please check (use df) before using space there.

Suraj

Re: Files and directories in /tmp and /var/tmp and their importance for system functionality

Hi JRF, Bill, Suraj

Many thanks for your patience in answering all the queries.

I need some clarifications.

When you mean "files" in your reply, I should take the general unix convention to also imply directories that are created in /tmp and /var/tmp Right?

On a 11iv3 system, i have the following for /etc/rc.config.d/clean_tmps file on my system. Can I be sure that this will clean up not only /tmp but also /var/tmp? Is it a bug/oversight in comments of the script file or by design? I learnt from other thread that /var/tmp will not be cleaned and that we need to edit the script /sbin/init.d/clean_tmp to add that functionality.

#!/sbin/sh
# @(#)B.11.31_LR
# List and/or clear temporary files
#
# LIST_TEMPS: Set to 1 to produce a listing of temporary files at startup.
#
# CLEAR_TMP: Set to 1 to remove all files from /tmp at startup.
#
LIST_TEMPS=1
CLEAR_TMP=0


Patience pays....but you will need pateince for that........
Bill Hassell
Honored Contributor

Re: Files and directories in /tmp and /var/tmp and their importance for system functionality

You are correct -- the clean_tmp script does not clear /var/tmp. You'll need to add that capability to the script. And yes, in Unix, a directory is also defined as a file. In all cases, the definition of tmp is for temporary files. For most applications, these files and directories can be removed without a problem during a reboot. Users should be aware that /tmp and /var/tmp are just that: temporary.

Currently, the settings in /etc/rc.config.d/clean_tmp:

LIST_TEMPS=1
CLEAR_TMP=0

will only list the files. I would change this to:

LIST_TEMPS=1
CLEAR_TMP=1


Bill Hassell, sysadmin
Suraj K Sankari
Honored Contributor

Re: Files and directories in /tmp and /var/tmp and their importance for system functionality

Hi,

In UNIX every thing is defined as a file.
If your /tmp getting full better ask the file owner to delete his/her file which is in /tmp

/var/tmp do not delete any file from there when you reboot your system it will automaticly clear.

Suraj