1834935 Members
2488 Online
110071 Solutions
New Discussion

tmp cleaning

 
SOLVED
Go to solution
hpuxrox
Respected Contributor

tmp cleaning

anyone have a down-n-dirty cron script to autoclean /tmp?
5 REPLIES 5
RAC_1
Honored Contributor
Solution

Re: tmp cleaning

Why down-n-dirty when you have /sbin/init.d/clean_tmps?

Or you can always do somthing like

find /tmp -type f -mtime +7|xargs rm -fr
Will remove files older than 7 days.

Anil
There is no substitute to HARDWORK
Helen French
Honored Contributor

Re: tmp cleaning

This can be included in your crontab file:

#Find,remove and report old unused files in /tmp

find /tmp \( -atime +14 -a -mtime +30 \) -exec ls -al {} \; -exec rm -r {} \; >> $temp

mailx -s "Reports of deleted files" mymailaddress@com.com < $temp
Life is a promise, fulfill it!
Shannon Petry
Honored Contributor

Re: tmp cleaning

There used to be a thread with lots of good scripts in it. It's not sticky, so maybe someone remembers the title and can post it.

Microsoft. When do you want a virus today?
Robert-Jan Goossens
Honored Contributor

Re: tmp cleaning

Hi,

20 00 * * 1 /usr/bin/find /tmp -type f -mtime +7 -exec rm {} \; >>/dev/null 2>&1

Regards,
Robert-Jan
Shannon Petry
Honored Contributor

Re: tmp cleaning

I know you gave a bunny, so do not award points.

I found the link to the script thread:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=123030

Be carefull what you remove in /tmp too, as it can cause X to crash if running, and other socket based applications with the socket in /tmp to die mid-run.

Regards,
Shannon
Microsoft. When do you want a virus today?