cron 定期削除

sambaのゴミ箱(.recycle)の定期削除はtmpの削除スクリプトを参考に作成した

#!/bin/sh
#
#
# clean_tmp. This script was split off cron.daily
# Please add your local changes to cron.daily.local
# since this file will be overwritten, when updating your system.
#
# Copyright (c) 1996-2002 SuSE Linux AG, Nuernberg, Germany.
#
# please send bugfixes or comments to http://www.suse.de/feedback.
#
# Author: Burchard Steinbild, 1996
#         Florian La Roche, 1996
#

#
# paranoia settings
#
umask 022

PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
#
# get information from /etc/sysconfig
#
if [ -f /etc/sysconfig/cron ] ; then
    . /etc/sysconfig/cron
fi

test "$MAX_DAYS_IN_TMP" -gt 0 2> /dev/null || exit 0
#
# Delete apropriate files in tmp directories.
#
OMIT=""
for i in $OWNER_TO_KEEP_IN_TMP ; do
    OMIT="$OMIT  ( ! -user $i )"
done

for TMP_DIR in $TMP_DIRS_TO_CLEAR ; do
  test -x /usr/bin/safe-rm && {
  find $TMP_DIR/. $OMIT ! -type d ! -type s ! -type p \
    -atime +$MAX_DAYS_IN_TMP -exec /usr/bin/safe-rm {} \;
  } || echo "Error: Can not find /usr/bin/safe-rm"
  find $TMP_DIR/. $OMIT -depth -type d -empty -mindepth 1 \
    -mtime +$MAX_DAYS_IN_TMP -exec /usr/bin/safe-rmdir {} \;
done

exit 0