User Tools

Site Tools


howtos:clean_up_directory_based_on_file_age

Differences

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

Link to this comparison view

howtos:clean_up_directory_based_on_file_age [d/m/Y H:i] (current)
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: d/m/Y H:i (external edit)