User Tools

Site Tools


howtos:clean_up_directory_based_on_file_age
#!/bin/bash

RELOCATE_AFTER_DAYS=5
REMOVE_AFTER_DAYS=30


find /srv/ftp/incoming -maxdepth 1 -type f -mtime +$RELOCATE_AFTER_DAYS | while read line; do
        mv "$line" /srv/ftp/incoming/attic/
done

find /srv/uploads -maxdepth 1 -type f -mtime +$RELOCATE_AFTER_DAYS | while read line; do
        mv "$line" /srv/uploads/attic/
done

find /srv/sftp/incoming -maxdepth 1 -type f -mtime +$RELOCATE_AFTER_DAYS | while read line; do
        mv "$line" /srv/sftp/incoming/attic/
done


find /srv/ftp/incoming/attic -maxdepth 1 -type f -mtime +$REMOVE_AFTER_DAYS | while read line; do
        rm "$line"
done

find /srv/uploads/attic -maxdepth 1 -type f -mtime +$REMOVE_AFTER_DAYS | while read line; do
        rm "$line"
done

find /srv/sftp/incoming/attic -maxdepth 1 -type f -mtime +$REMOVE_AFTER_DAYS | while read line; do
        rm "$line"
done
howtos/clean_up_directory_based_on_file_age.txt · Last modified: 02/12/2018 20:34 by 127.0.0.1