Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Whats a good strategy for clearing /tmp and /usr/tmp?

clearing good strategy tmp usr
0
10 Posted

Whats a good strategy for clearing /tmp and /usr/tmp?

0
10

Two suggestions (to be run from cron) are below. The first being the optimal solution: #!/bin/sh DAYS=7 find /tmp /usr/tmp -depth -hidden -fsonly hfs -atime +$DAYS -exec rm -rf {} \; The -depth option ensures no directory is removed before its contents, -fsonly hfs is because occasionally I’ve NFS-mounted stuff there and it’s better to do the clearing in the machine where it’s local, and -hidden is in case CDF’s appear there for some reason. (Thanks to Tapani Tarvainen and Michael Sternberg ) #!/bin/sh DAYS=7 DIRS=”/tmp /usr/tmp” find $DIRS -type d -atime +$DAYS -exec rm -rf {} \; find $DIRS ! -type d -atime +$DAYS -exec rm -f {} \; (Thanks to Rich Jennings, HP and Michael Sternberg

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.