Operating System - HP-UX
1822273 Members
3893 Online
109642 Solutions
New Discussion юеВ

Re: how do HP-UX create temporary files

 
Ridzuan Zakaria
Frequent Advisor

how do HP-UX create temporary files

Hi,

Recently, my /var/tmp has reached 100% space usage due to some files created by oracle shadow process. My server run on HP-UX 11.00 64 bit. I have been wondering how do HP-UX create a temporary file, does it use tempnam() or tmpnam(). It seems that even if I change my TMPDIR to different location, the temporary files were still being created in /var/tmp. Look likes it use tmpnam() to create temporary files because tmpnam() will always create file in /var/tmp no matter what is the value of TMPDIR.

Anyone has any information regarding this issue.

Thanks in advance.
quest for perfections
9 REPLIES 9
Christopher Caldwell
Honored Contributor

Re: how do HP-UX create temporary files

temp file creation is application specific (vi, Oracle, xx are all subject to doing it differently). Some times it's done insecurely - see the tmp file creation/predictable file name vulnerability of the man command.

Use lsof to see what's making files in /var/tmp - if Oracle is the hog, log a tar with Oracle to get them to help you figure out what's happening.
James R. Ferguson
Acclaimed Contributor

Re: how do HP-UX create temporary files

Hi:

Only some utilities use the environmental variable TMPDIR to select the directory for temporary files. 'sort' (using the '-t') option is one of them).

Regards!

...JRF...
Sanjay_6
Honored Contributor

Re: how do HP-UX create temporary files

Hi Ridzuan,

You need to set and export the variable TMPDIR, so that it points to the directory you want it to use.

Hope this helps.

Regds

Sanjay_6
Honored Contributor

Re: how do HP-UX create temporary files

Hi Ridzuan,

you may also want to take a look at this thread,

http://us-support2.external.hp.com/cki/bin/doc.pl/sid=a8c720af052550bab9/screen=ckiDisplayDocument?docId=200000012779122

Hope this helps.

Regds
Sridhar Bhaskarla
Honored Contributor

Re: how do HP-UX create temporary files

Hi Ridzuan,

HP-UX OS doesn't create temp files on it's own but the utilities/softwares do. For ex., if we edit a file, the copy will be placed under /var/tmp/ as Ex$$ ($$ being the pid). So if someone edits a 50MB file /var will be increased by 50MB due to this copy. If the vi is abnormally shut (like closing the telnet window), this will remain and occupy the space.
So, it is a good practice to remove the files that are 3-4 days older from these temp directories.

Another way is by people like me who create temp files in their scripts/programs but do not clean up before exiting them. So, they also will remain.

-Sri

You may be disappointed if you fail, but you are doomed if you don't try
A. Clay Stephenson
Acclaimed Contributor

Re: how do HP-UX create temporary files

Hi:

It varies. If the programmers have been beaten over the head and told to honor the TMPDIR convention then you should be fine. The tempnam() and tmpnam() functions do honor this. Also, bear in mind that TMPDIR must be set before the process is started or it will have no effect.

When the programmers are really sneaky they'll do this to you:

fname = tmpnam(char *) NULL);
fdes = open(fname,O_RDWR | O_CREAT,0600);
unlink(fname);
...
...
...
close(fdes);

In this case, even though the file has been unlinked and thus you won't see it, as long as the process has it open, the space is used. This is a pretty standard technique and in fact the tmpfile() function does this.

Clay
If it ain't broke, I can fix that.
Ridzuan Zakaria
Frequent Advisor

Re: how do HP-UX create temporary files

Hi,

Chris, I have opened a TAR with Oracle regarding this issue and Oracle's feedback is indicate that this is O/S related problem (dependency) and ask me to check with HP. On Sun TMPDIR directory can be redirect because i use tempnam() instead of tmpnam (This is according to Oracle).

Anyway thanks for the feedbacks. I guess I will create cron to cleanup the directory.

Thanks.

I also notice that if I use crontab -e , a temporary file will be created on /var/tmp on HP but /tmp for Sun Solaris.

quest for perfections
Christopher Caldwell
Honored Contributor

Re: how do HP-UX create temporary files

TMPDIR generally works on HP (if the application developer (Oracle) honors the TMPDIR environment variable -- they're copping out on you if they push you over to HP - they should know how their code works).

Here's a snip of man tmpnam:

tempnam() allows the user to control the choice of a
directory. The argument dir points to the name of
the directory in which the file is to be created.
If dir is NULL or points to a string that is not
an appropriate directory name, the path-prefix
defined as P_tmpdir in the header file
is used. If that directory is not accessible,
/tmp is used as a last resort. This entire
sequence can be up-staged by providing an
environment variable TMPDIR in the user's
environment, whose value is the name of the
desired temporary-file directory.

tmpfile(3) and mktemp(3) are also available.

BTW, check the perms of /var/tmp - we make the perms on tmp directories 1777 instead of 777; which means that you have to own the file to remove it from tmp. These perms break some setuid programs like sendmail hooked to procmail.

Yogeeraj_1
Honored Contributor

Re: how do HP-UX create temporary files

Hi,

I guess you should be having problems installing Oracle 9iAS. :)

I had similar problems on my HP_UX 11 64-bits.

I finally ended exporting TMP, TMP_DIR and TMPDIR.

It worked the dirty way!! I can't tell you for sure which one it used.

I am sure Oracle will be able to answer this question much better.

regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)