# running clean-tmps in multiple directories



## vatson (Apr 27, 2010)

I discovered that on two of our servers the 110.clean-tmps periodic script isn't doing it's job. One of these servers is FreeBSD 6.3, the other is 7.2.

The following is written in /etc/periodic.conf:

```
daily_clean_tmps_enable="YES"
daily_clean_tmps_dirs="/var/virusmails /var/amavis/tmp"
daily_clean_tmps_days="14"
```

However, the files in /var/virusmails date back to 2008. I tried running the /etc/periodic/daily/110.clean-tmps script manually - it runs but still doesn't clean up any files.

On other servers, where I don't have such problem, I have only one directory set in daily_clean_tmps_dirs. This leads me to think that I'm making a mistake in specifying multiple directories here, but there are many examples on the web where this is exactly how it's done. The manpage just says it should be a 'list of directories'. What am I doing wrong?


----------



## DutchDaemon (Apr 27, 2010)

Run [cmd=]sh -x /etc/periodic/daily/110.clean-tmps[/cmd] or even [cmd=]sh -xv /etc/periodic/daily/110.clean-tmps[/cmd] and watch the output.

With your settings (I created these two directories), I see this:


```
+ daily_clean_tmps_enable=YES
+ daily_clean_tmps_dirs='/var/virusmails /var/amavis/tmp'
+ daily_clean_tmps_days=14
+ sourced_files=:/etc/periodic.conf::/etc/periodic.conf.local:
+ [ -r /etc/periodic.conf.local ]
+ [ -z 14 ]
+ echo ''

+ echo 'Removing old temporary files:'
Removing old temporary files:

{ snip }

+ [ .var/virusmails != ./var/virusmails -a -d /var/virusmails ]
+ cd /var/virusmails
+ find -d . -type f -atime +14 -mtime +14 -ctime +14 ! -name '.X*-lock' ! -name .X11-unix ! -name .ICE-unix ! -name .font-unix ! -name .XIM-unix 
! -name quota.user ! -name quota.group -delete -print
+ sed 's,^\.,  /var/virusmails,'
+ find -d . ! -name . -type d -empty -mtime +14 ! -name '.X*-lock' ! -name .X11-unix ! -name .ICE-unix ! -name .font-unix ! -name .XIM-unix ! 
-name quota.user ! -name quota.group -delete -print
+ [ .var/amavis/tmp != ./var/amavis/tmp -a -d /var/amavis/tmp ]
+ cd /var/amavis/tmp
+ find -d . -type f -atime+ sed 's,^\.,  /var/amavis/tmp,'
 +14 -mtime +14 -ctime +14 ! -name '.X*-lock' ! -name .X11-unix ! -name .ICE-unix ! -name .font-unix ! -name .XIM-unix ! -name quota.user ! 
-name quota.group -delete -print
+ find -d . ! -name . -type d -empty -mtime +14 ! -name '.X*-lock' ! -name .X11-unix ! -name .ICE-unix ! -name .font-unix ! -name .XIM-unix ! 
-name quota.user ! -name quota.group -delete -print
```

So it looks for files and directories older than 14 days, other than the ones exempted by the '! -name' statements. Are these the ones you don't see deleted?


----------



## vatson (Apr 29, 2010)

Thanks for the debugging tip. This led me to discover that my nightly backup process is changing atime of these files, so atime never gets 14 days old. Hence, no files are ever eligible for deletion.


----------



## DutchDaemon (Apr 29, 2010)

Switch on 'noatime' (fstab(5)) on /var, and you should see results. Well, in two weeks ..


----------

