Operating System - HP-UX
1830720 Members
2474 Online
110015 Solutions
New Discussion

Autoclear of /tmp on reboot

 
SOLVED
Go to solution
hpuxrox
Respected Contributor

Autoclear of /tmp on reboot

I know about editing /etc/rc.config.d/clean_tmps to activate. I am looking for recommendations for autoclearing /tmp on a system reboot.

Such as,

1. Why would it need to be done.
2. Why isn't it set that way on default.
3. etc....

Thanks,

Yates
15 REPLIES 15
Bill McNAMARA_1
Honored Contributor

Re: Autoclear of /tmp on reboot

I like to turn it on.. but:

> 1. Why would it need to be done.

Save space?

> 2. Why isn't it set that way on default.

Because I turned it on once, and got loads of emails from angry users saying their files that they ftp'd vanished after reboot.


> 3. etc....
Remember you are root and can write anywhere you like, but your users can't... tmp is free space for them.

Later,
Bill
It works for me (tm)
Stefan Farrelly
Honored Contributor

Re: Autoclear of /tmp on reboot


1. If you dont cleanup /tmp regularly it WILL eventually fill up which will then cause you problems.

2. Sometimes people actually put stuff in /tmp which they want to keep for a while, hence HP dont automatically clean it out on reboot. Sun does!

3. At all the sites ive worked its almost always been the same - 1 weeks worth is enough, anything older delete. Just in case you dont reboot your server regularly setup a cron job to clean it out weekly.

Im from Palmerston North, New Zealand, but somehow ended up in London...
S.K. Chan
Honored Contributor

Re: Autoclear of /tmp on reboot

Is a matter of preference and how your environment operates really. By NOT turning it ON by default it a way of saying .. "it's up to you"..
In our environment we have scheduled downtime for us "admins" to do system maintenance once a month and all our users know that files in /tmp will be wiped out upon reboot.
There are also other installation that regularly "housekeep" what's in /tmp by limiting it to say a week worth of files and typically this is done via cron. In this case "clean_tmps" is OFF.
Mark Greene_1
Honored Contributor

Re: Autoclear of /tmp on reboot

this is a bit of a reach, but if a process crashed and created a core file in /tmp and you then rebooted the system for whatever reason, if /tmp was cleared automatically, you'd not have the core file to diagnose the crash.

mark
the future will be a lot like now, only later
MANOJ SRIVASTAVA
Honored Contributor

Re: Autoclear of /tmp on reboot

Hi Yates


Oner more reason , if the processes use to write tmp files in /tmp direcorty and you dont clean it then the porcess may complain that the files alerady exist and hence fail . I would definatley clean /tmp at the startup

Manoj Srivastava
Helen French
Honored Contributor

Re: Autoclear of /tmp on reboot

My thoughts:

Why enable:
1) Freeing space in /tmp, which is defenitely an important file system to have free space on it.
2) To keep automatic deletion of temporary files; no man power required.

Why not default:
1) As in all other case, it's configuration choice given by HP. If you want do it; otherwise don't.

Why disable:
1) Accidental deletion of some files stored under /tmp. May be some logs/patch bundles/downloads/install files etc.
2) If sys admin can periodically check /tmp and delete unwanted files, then disable it.

I personally kept it disabled and do that stuff myself.
Life is a promise, fulfill it!
Pete Randall
Outstanding Contributor
Solution

Re: Autoclear of /tmp on reboot

Yates,

Personally, I'd go for a cron job that cleans everything more than one week old out of /tmp. That way you're not dependant on having to re-boot in order to get it cleared out and you can control how often it gets cleaned and can fine tune the retention time period.

Semper Fi,
Pete

Pete
hpuxrox
Respected Contributor

Re: Autoclear of /tmp on reboot

Thanks all,

What other filesystems are good to keep clean other than /tmp.
Pete Randall
Outstanding Contributor

Re: Autoclear of /tmp on reboot

Yates,

I like to keep an eye on /var (I do a bdf and a du -sk /var/* and mail it to myself every day so I can see what's growing under /var). You can clean out /var/tmp much the same as /tmp. You need to keep an eye on all the log files that your applications create. My programmers are "supposed" to always put their logfiles in a particular directory that I clean with a find command via cron. There's probably more but that's pretty much my list.

Hope this helps,
Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: Autoclear of /tmp on reboot

Because most UNIX boxes stay up for months, it's rather silly to have an rc script do this. As has been mentioned the better way is to have a cron job scan for files older than some given value and remove them. /tmp, /var/tmp are good candidates. It is also a good idea to have a daemon to remove old database archive logs.

As part of this same routine, you might want to also trim various log files.
If it ain't broke, I can fix that.
Ernesto Cappello
Trusted Contributor

Re: Autoclear of /tmp on reboot

Hi
I'm HP-UX 11.0 and in /etc/rc.config.d there is a file called clean_tmps and you must change the value of variable CLEAR_TMP=1.
This is my "clean_tmps" file.

#!/sbin/sh
# @(#) $Revision: 72.4 $
# 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=1


Regards
Ernesto.
Thierry Poels_1
Honored Contributor

Re: Autoclear of /tmp on reboot

Hi,

I strongly agree "OLD" files need to be removed from /tmp and /var/tmp regularly.
The definition of "OLD" depends on your needs and disk space, it can be one day or several days.

But I advise against clearing /tmp on reboot:
- users know they put their files on a temporary location, but they won't accept that their files get removed 2 minutes later because of a system reboot (wanted or unwanted).
- after a system crash, you might loose important temporary files which indicate where jobs and/or applications aborted due to the crash.
- sysadmins (or contractors) also use /tmp to store temporary files or copies of files, they need AFTER a reboot. (I will never forget this one ;)

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
hpuxrox
Respected Contributor

Re: Autoclear of /tmp on reboot

What would be the correct find syntax to clear tmp of files over a week old?
Pete Randall
Outstanding Contributor

Re: Autoclear of /tmp on reboot

Yates,

Try:

find /tmp -mtime +7 -exec rm {} \;

Pete

Pete
S.K. Chan
Honored Contributor

Re: Autoclear of /tmp on reboot

This would work ..

# find /tmp -type f -mtime +7 -exec rm -f {} \;

test it first ..

# find /tmp -type f -mtime +7 -exec ll {} \; | more