Operating System - HP-UX
1833017 Members
2373 Online
110048 Solutions
New Discussion

How to clean files in /tmp dir while reboot

 
SOLVED
Go to solution
Ezhilarasan
Occasional Advisor

How to clean files in /tmp dir while reboot

Hi,

How to clean files in /tmp dir while reboot.
Will it clean every thing in that dir or
what kind of files and dir will it clean ?

Thanks
R. Exhil
5 REPLIES 5
Sridhar Bhaskarla
Honored Contributor

Re: How to clean files in /tmp dir while reboot

Hi,

It cleans crashed files of editors and recovers them. It won't touch anything other than that.

The file that does this job is /sbin/init.d/clean_ex. Run it manually before rebooting the server if it has been up and running for a long time just before rebooting the box.

/sbin/init.d/clean_ex start.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Ian Kidd_1
Trusted Contributor

Re: How to clean files in /tmp dir while reboot

there's a couple of files in /sbin/init.d. to clean /tmp out you want /sbin/init.d/clean_tmps

it uses /etc/rc.config.d/clean_tmps to determine whether or not to turn on as the system is coming up and is run at the /sbin/rc2.d (S204clean_tmps on my system)
If at first you don't succeed, go to the ITRC
Michael Tully
Honored Contributor
Solution

Re: How to clean files in /tmp dir while reboot

You may find turning this on, (/etc/rc.config/clean_tmps) will not do exactly what you want. I'd suggest you do a slightly different approach and implement an automatic job through 'cron' that cleans up files in /tmp that are say more than a week old.
Anyone for a Mutiny ?
Ian Kidd_1
Trusted Contributor

Re: How to clean files in /tmp dir while reboot

Michael T. raises a good point. there is no control when you turn on clean_tmps. When the server comes up it will issue a:
rm -rf !(lost+found) in /tmp - blowing away everything in there except for lost+found. So if your server panics and reboots, it WILL erase everyting in /tmp - including things that you might have wanted to keep. Which is the reason the default setting in /etc/rc.config.d/clean_tmps is:
LIST_TEMPS=1
CLEAR_TMP=0

By the way, LIST_TEMPS=1 is what causes the /tmp listing in your /etc/rc.log.
If at first you don't succeed, go to the ITRC
RAC_1
Honored Contributor

Re: How to clean files in /tmp dir while reboot

/etc/rc.config.d/clean_tmps is the file you should look at. Buit do not set it to 1 or everthing will be deleted from /tmp.

A good approch would be deleteing old file depending on your requirement.
something like

find /tmp -type f/d -mtime +35 -exec rm -fr {} \;

There is no substitute to HARDWORK