Question

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?

Was it helpful?

Solution

How about:

find /tmp !-user root -delete

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top