110.clean-tmps revision 28263
128263Spst#!/bin/sh
228263Spst#
328263Spst# $Id: 110.clean-tmps,v 1.1.1.1 1997/08/12 17:51:15 pst Exp $
428263Spst#
528263Spst# This is a security hole, never use 'find' on a public directory
628263Spst# with -exec rm -f as root.  This can be exploited to delete any file
728263Spst# on the system.
828263Spst#
928263Spst# Use at your own risk, but for a long-living system, this might come
1028263Spst# more useful than the boot-time cleaning of /tmp.  If /var/tmp and
1128263Spst# /tmp are symlinked together, only one of the below will actually
1228263Spst# run.
1328263Spst#
1428263Spst
1528263Spstexit 0		# do not run by default
1628263Spst
1728263Spstif [ -d /tmp ]; then
1828263Spst    cd /tmp && {
1928263Spst	find . -type f -atime +3 -ctime +3 ! -name '.X*-lock' \
2028263Spst		-exec rm -f -- {} \;
2128263Spst	find -d . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
2228263Spst		>/dev/null 2>&1
2328263Spst    }
2428263Spstfi
2528263Spst
2628263Spstif [ -d /var/tmp ]; then
2728263Spst    cd /var/tmp && {
2828263Spst	find . ! -name . -atime +7 -ctime +3 -exec rm -f -- {} \;
2928263Spst	find -d . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \
3028263Spst		>/dev/null 2>&1
3128263Spst    }
3228263Spstfi
33