diff --git a/log-cleanup/airflow-log-cleanup.py b/log-cleanup/airflow-log-cleanup.py index e12f5a9..7c11652 100755 --- a/log-cleanup/airflow-log-cleanup.py +++ b/log-cleanup/airflow-log-cleanup.py @@ -175,20 +175,23 @@ echo "" echo "Running Cleanup Process..." - FIND_STATEMENT="find ${BASE_LOG_FOLDER}/*/* -type f -mtime \ + # Delete log files + FIND_STATEMENT="find ${BASE_LOG_FOLDER} -type f -mtime \ +${MAX_LOG_AGE_IN_DAYS}" DELETE_STMT="${FIND_STATEMENT} -exec rm -f {} \;" cleanup "${FIND_STATEMENT}" "${DELETE_STMT}" CLEANUP_EXIT_CODE=$? - FIND_STATEMENT="find ${BASE_LOG_FOLDER}/*/* -type d -empty" + # Delete empty DAG run folders + FIND_STATEMENT="find ${BASE_LOG_FOLDER} -type d -empty" DELETE_STMT="${FIND_STATEMENT} -prune -exec rm -rf {} \;" cleanup "${FIND_STATEMENT}" "${DELETE_STMT}" CLEANUP_EXIT_CODE=$? - FIND_STATEMENT="find ${BASE_LOG_FOLDER}/* -type d -empty" + # Delete empty DAG folders + FIND_STATEMENT="find ${BASE_LOG_FOLDER} -type d -empty" DELETE_STMT="${FIND_STATEMENT} -prune -exec rm -rf {} \;" cleanup "${FIND_STATEMENT}" "${DELETE_STMT}"