0

Hi with a (bad) script of mine I filled up lots of files in /tmp folder. Now when I do ls in tmp folder it doesn't return anything (i waited for more than an hour). Hence I am not able to cleanup the directory. I tried reboot as well. I can see the tmpwatch is running but it is either too slow or not working at all.

Is there any (quick) way I can clean up /tmp files?

wantro
  • 373
  • 1
  • 7
  • 18

2 Answers2

2

How about:

find /tmp !-user root -delete

you can add -mtime <gracedays> switch if you want and cron it

Stephane Rouberol
  • 4,286
  • 19
  • 18
1

If you have an idea of the filename structure you can do something like:

find . -name "stuff*" -exec rm {} \;

To clean up old php sessions in my tmp dir, I have find . -name "sess_*" -atime +1h -exec rm {} \; in a cron job.

If you're using rm, you might get an error that there are too many files, which is why

Cryo
  • 11
  • 3
  • yes I have already tried it. But it doesn't even return anything – wantro Aug 21 '12 at 12:24
  • Well, it seems it is doing the job. But since there was no progress it gave me a feeling that it's stuck. Now, I gave find . -name "stuff*" -exec rm -vf {} \; and gives me the status. All good. Thanks for the help. – wantro Aug 21 '12 at 13:15