User Tools

Site Tools


howtos:clean_up_directory_based_on_file_age
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


howtos:clean_up_directory_based_on_file_age [02/12/2018 21:34] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +<code>
 +#!/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
 +</code>
howtos/clean_up_directory_based_on_file_age.txt · Last modified: 02/12/2018 21:34 by 127.0.0.1