Operating System - HP-UX
1833154 Members
3049 Online
110051 Solutions
New Discussion

scripts available to clean up /tmp

 
SOLVED
Go to solution
Joe Profaizer
Super Advisor

scripts available to clean up /tmp

Just looking for some tested and tried scripts to clean up /tmp. Anything will help.

Thanks,

..Joe
10 REPLIES 10
Pete Randall
Outstanding Contributor
Solution

Re: scripts available to clean up /tmp

We use a cron job that simply does

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

PEte

Pete
Martin Johnson
Honored Contributor

Re: scripts available to clean up /tmp

We have a cron entry to remove anything over 30 days old:

30 23 * * 5 find /tmp/* -atime +30 -exec rm {} \;

HTH
Marty
Jean-Luc Oudart
Honored Contributor

Re: scripts available to clean up /tmp

Pete Randall
Outstanding Contributor

Re: scripts available to clean up /tmp

Joe,

There's some discussion of other alternatives in this thread:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x30108f960573d611abdb0090277a778c,00.html

Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: scripts available to clean up /tmp

Well, it could be as simple as something like:

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

However, I do not like this approach because you are fixing the symptoms rather than the problem itself. I absolutely beat into the heads of all developers that this is their responsibility; I consider leaving temp files about as bad as allowing memory leaks to creep into code. I will admit that if someone does a kill -9, there is not a whole lot to be done about that inside the code. I have another baseball bat to deal with that problem.
If it ain't broke, I can fix that.
Sajid_1
Honored Contributor

Re: scripts available to clean up /tmp

hello,

this is what I do - find old unused files in the tmp dir and remove them:
# find /tmp \( -atime +14 -a -mtime +30 \) -exec rm -r {} \;
learn unix ..
Sajid_1
Honored Contributor

Re: scripts available to clean up /tmp

hi,

You can also set this on the crontab and will do it automatically:
# crontab -e
add entry:
07 00 * * * find /tmp \( -atime +14 -a -mtime +30 \) -exec rm -r {} \;
learn unix ..
Joe Profaizer
Super Advisor

Re: scripts available to clean up /tmp

All good answers. I guess it's taylored to your respective environment and rules.

...Joe
H.Merijn Brand (procura
Honored Contributor

Re: scripts available to clean up /tmp

Attached a script that runs from cron. Tweak to your needs

Enjoy, Have FUN! H.Merijn
H.Merijn Brand (procura
Honored Contributor

Re: scripts available to clean up /tmp

Trying the attach again.
Enjoy, Have FUN! H.Merijn