View | Details | Raw Unified | Return to bug 30938
Collapse All | Expand All

(-)etc/periodic/daily/110.clean-tmps (-3 / +27 lines)
Lines 22-32 Link Here
22
		'$daily_clean_tmps_days is not'
22
		'$daily_clean_tmps_days is not'
23
	    rc=2
23
	    rc=2
24
	else
24
	else
25
	    clean_ssh_agent=NO
26
	    case "$daily_clean_tmps_ssh_enable" in
27
		[Yy][Ee][Ss])
28
		    clean_ssh_agent=YES
29
		    if [ -z "$daily_clean_tmps_ssh_days" ]
30
		    then
31
			daily_clean_tmps_ssh_days=$daily_clean_tmps_days
32
		    fi
33
	    esac
25
	    echo ""
34
	    echo ""
26
	    echo "Removing old temporary files:"
35
	    echo "Removing old temporary files:"
27
36
28
	    set -f noglob
37
	    set -f noglob
29
	    args="-atime +$daily_clean_tmps_days -mtime +$daily_clean_tmps_days"
38
	    args="-atime +$daily_clean_tmps_days -mtime +$daily_clean_tmps_days"
39
	    ssh_args="-atime +$daily_clean_tmps_ssh_days -mtime +$daily_clean_tmps_ssh_days"
30
	    [ -n "$daily_clean_tmps_ignore" ] &&
40
	    [ -n "$daily_clean_tmps_ignore" ] &&
31
		args="$args "`echo " ${daily_clean_tmps_ignore% }" |
41
		args="$args "`echo " ${daily_clean_tmps_ignore% }" |
32
		    sed 's/[ 	][ 	]*/ ! -name /g'`
42
		    sed 's/[ 	][ 	]*/ ! -name /g'`
Lines 36-53 Link Here
36
		*)
46
		*)
37
		    print=;;
47
		    print=;;
38
	    esac
48
	    esac
49
 	    [ -z "$daily_clean_tmps_dir_days" ] && daily_clean_tmps_dir_days=$daily_clean_tmps_days
39
50
40
	    rc=$(for dir in $daily_clean_tmps_dirs
51
	    rc=$(for dir in $daily_clean_tmps_dirs
41
		do
52
		do
42
		    [ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && {
53
		    [ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && {
43
			find -d . -type f $args -delete $print
54
			find -d . -type f $args -delete $print
44
			find -d . ! -name . -type d -empty -mtime \
55
			find -d . ! -name . -type d -empty -mtime \
45
			    +$daily_clean_tmps_days -delete $print
56
 			    +$daily_clean_tmps_dir_days -delete $print
46
		    } | sed "s,^\\.,  $dir,"
57
			if [ "$clean_ssh_agent" = "YES" ]
58
			then
59
			    set +f noglob
60
			    ssh_dirs=$(echo ssh-*)
61
			    set -f noglob
62
			    if [ -n "$ssh_dirs" -a "$ssh_dirs" != "ssh-*" ]
63
			    then
64
				find -d $ssh_dirs -depth \
65
				    \( -type s $ssh_args -name agent.\[\0-9]\* \
66
					-delete $print \) -o \
67
				    \( -type d -empty -delete $print \);
68
			    fi
69
			fi
70
		    } | sed "s,^\\.,  $dir,; s,^\\(ssh-[^ \/]*\\),  $dir/\\1,;"
47
		done | tee /dev/stderr | wc -l)
71
		done | tee /dev/stderr | wc -l)
48
	    [ -z "$print" ] && rc=0
72
	    [ -z "$print" ] && rc=0
49
	    [ $rc -gt 1 ] && rc=1
73
	    [ $rc -gt 1 ] && rc=1
50
	    set -f glob
74
	    set +f noglob
51
	fi;;
75
	fi;;
52
76
53
    *)  rc=0;;
77
    *)  rc=0;;
(-)etc/defaults/periodic.conf (+3 lines)
Lines 42-49 Link Here
42
daily_clean_tmps_enable="NO"				# Delete stuff daily
42
daily_clean_tmps_enable="NO"				# Delete stuff daily
43
daily_clean_tmps_dirs="/tmp"				# Delete under here
43
daily_clean_tmps_dirs="/tmp"				# Delete under here
44
daily_clean_tmps_days="3"				# If not accessed for
44
daily_clean_tmps_days="3"				# If not accessed for
45
daily_clean_tmps_dir_days="3"				# If dir not accessed
45
daily_clean_tmps_ignore=".X*-lock quota.user quota.group" # Don't delete these
46
daily_clean_tmps_ignore=".X*-lock quota.user quota.group" # Don't delete these
46
daily_clean_tmps_verbose="YES"				# Mention files deleted
47
daily_clean_tmps_verbose="YES"				# Mention files deleted
48
daily_clean_tmps_ssh_enable="NO"			# Delete ssh agent stuff
49
daily_clean_tmps_ssh_days="3"				# If not accessed for
47
50
48
# 120.clean-preserve
51
# 120.clean-preserve
49
daily_clean_preserve_enable="YES"			# Delete files daily
52
daily_clean_preserve_enable="YES"			# Delete files daily
(-)share/man/man5/periodic.conf.5 (+16 lines)
Lines 177-182 Link Here
177
.Va daily_clean_tmps_enable
177
.Va daily_clean_tmps_enable
178
is set, this must also be set to the number of days old that a file's access
178
is set, this must also be set to the number of days old that a file's access
179
and modification times must be before it's deleted.
179
and modification times must be before it's deleted.
180
.It Va daily_clean_tmps_dir_days
181
.Pq Vt num
182
If you want a different amount of time after which directories are deleted
183
you can set this variable. Its default is the value of
184
.Va daily_clean_tmps_days.
180
.It Va daily_clean_tmps_ignore
185
.It Va daily_clean_tmps_ignore
181
.Pq Vt str
186
.Pq Vt str
182
Set to the list of files that should not be deleted when
187
Set to the list of files that should not be deleted when
Lines 189-194 Link Here
189
Set to
194
Set to
190
.Dq YES
195
.Dq YES
191
if you want the removed files to be reported in your daily output.
196
if you want the removed files to be reported in your daily output.
197
.It Va daily_clean_tmps_ssh_enable
198
.Pq Vt bool
199
Set to
200
.Dq YES
201
if you want to clear sockets of ssh-agent in your temporary directories daily.
202
.It Va daily_clean_tmps_ssh_days
203
.Pq Vt num
204
When
205
.Va daily_clean_tmps_ssh_enable
206
is set, this must also be set to the number of days old that a ssh-agent socket
207
access and modification times must be before it's deleted.
192
.It Va daily_clean_preserve_enable
208
.It Va daily_clean_preserve_enable
193
.Pq Vt bool
209
.Pq Vt bool
194
Set to
210
Set to

Return to bug 30938