1838105 Members
3744 Online
110124 Solutions
New Discussion

Re: /var/tmp

 
SOLVED
Go to solution
eric stewart
Frequent Advisor

/var/tmp

I have a systems group that is skeptical about removing any files. There are files in /var/tmp from Feb 1999 and I get permission problems sometimes because of these old files.
Can the experts tell me what /var/tmp is used for and under what criteria they remove the files in that directory. Is there some doc on the recommeded removal period like 30 days after last reboot?
TIA
Good help is easy to find within forums
8 REPLIES 8
federico_3
Honored Contributor

Re: /var/tmp

In /var/tmp there are temporary files generated by commands in the /usr hierarchy.

I would delete files older than 3 days..


federico
Andreas Voss
Honored Contributor

Re: /var/tmp

Hi,

files under /var/tmp are usualy temporary files the can be removed after each reboot.
User have to take care not storing any important data at this location.

Regards
f. halili
Trusted Contributor

Re: /var/tmp

some processes will create temporary files in /var/tmp and should (if they terminate correctly) remove their files. Clear up /var/tmp of files not accessed in more than 7 days.
derekh
James R. Ferguson
Acclaimed Contributor
Solution

Re: /var/tmp

Eric:

/var/tmp/ can most certainly be cleaned up. Temporary files from script installs are placed here as are vi recovery files. The vi recovery files have the format "Ex" where was the pid of the vi process. You can script a cleanup for this directory and cron it accordingly. For example:

# find /var/tmp -mtime +30 -exec rm {} \;

...JRF...
CHRIS_ANORUO
Honored Contributor

Re: /var/tmp

In /sbin/init.d/clean_tmps files include /var/tmp as another directory to be cleaned up when system boots. You can activate this function (if you have not) from /etc/rc.config.d/clean_tmps file by setting the option to 1.
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Andreas Voss
Honored Contributor

Re: /var/tmp

Hi,

let me correct Chris reply:
Yes there is a file /sbin/init.d/clean_tmps BUT when you're looking in it you will find that ONLY /tmp is cleaned, NOT /var/tmp.
(/var/tmp is only listed, not cleaned)

Regards
Cheryl Griffin
Honored Contributor

Re: /var/tmp

You can also use the "file" command to see what command/application created the file. As routine maintenance, you should clean /var/tmp. There is a "Filesystem Full" white paper in the ITRC that has helpful suggestions on how to keep the system tidy.

# ll /var/tmp
-rw-r--r-- 1 root sys 1241 AAAa00396

# file AAAa00396
English Text

# more AAAa00396
======= 10/16/00 10:49:01 EDT BEGIN swinstall SESSION (interactive)
NOTE: The interactive UI was invoked, since no software was specified.
* Session started for user "root@rong".

As you can see, this file was created by swinstall.
"Downtime is a Crime."
Kevin Ernst
Regular Advisor

Re: /var/tmp

Eric:

But why is it that you're getting permissions problems because of the old files? Are your scripts using the same temp file name over again each time they run?

If that's the case, try creating the temp file names using 'mktemp' (see the man page), or use file names that contain the process number--which should be unique most of the time--like this:

TEMPFILE="yourscript-$$.tmp" (Bourne shell)
set TEMPFILE="yourscript-$$.tmp" (C shell)

Use 'trap' (Bourne) or 'onintr' (C shell) to remove the temp files if your script terminates unexpectedly. The way I do it for Bourne shell is something like this:

# Signal '0' is a normal termination:
trap "rm -f ${TEMPFILE:?'Undefined! Not removing any files.'}" 0
# If we get signals 1, 2, or 15, exit with nonzero status (failure):
trap "rm -f ${TEMPFILE:?'Undefined! Not removing any files.'}; exit 1" 1 2 15

(I hope I didn't make any typos)