From bb33aba93b936c812646ca44f20f10348c89b032 Mon Sep 17 00:00:00 2001 From: Greg Anders Date: Sat, 4 Mar 2017 23:03:55 -0600 Subject: [PATCH] Use proper find syntax --- bin/janitor | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/janitor b/bin/janitor index b3fc0d3..9dc597b 100755 --- a/bin/janitor +++ b/bin/janitor @@ -17,16 +17,15 @@ if [ -z "$TARGET_DIR" -o -z "$DAYS_TO_KEEP" ]; then exit 1 fi - -function clean() { +function sweep() { if [ $# -eq 0 ]; then exit 1 fi if [ ! -z "$TRASH_DIR" ]; then - rsync -a "$1" "$TRASH_DIR" + rsync -a "$1" "$TRASH_DIR" 2>/dev/null fi - rm -rf "$1" + rm -rf "$1" 2>/dev/null LOG="$JANITOR_DIR/logs/janitor_$(date +"%Y%m%d").log" @@ -36,6 +35,6 @@ function clean() { echo "${1##*/}" >> "$LOG" } -export -f clean +export -f sweep -find "$TARGET_DIR" -mtime +$DAYS_TO_KEEP -depth 1 -exec bash -c 'clean "$0"' {} \; +find "$TARGET_DIR" -mindepth 1 -maxdepth 1 -mtime +$DAYS_TO_KEEP -exec bash -c 'sweep "$0"' {} \; 2>/dev/null -- 2.26.2