Advertisement
dyunin

Untitled

Apr 9th, 2020
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.41 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ftp_dir="path/to/catalog"
  4. archive_dir="$ftp_dir/archive"
  5. datetime=$(date +%d.%m.%Y)
  6. remove_days="30"
  7.  
  8. if [[ $(find $ftp_dir -maxdepth 1 -type f | wc -l) == 0 ]]; then
  9.  exit 0
  10. else
  11.   mkdir $archive_dir/$datetime
  12.   find $ftp_dir -maxdepth 1 -type f -print0 | xargs -0 -I {} mv {} $archive_dir/$datetime
  13.   chown -R www-data: $archive_dir/$datetime
  14. fi
  15.  
  16. find $archive_dir  -mtime +$remove_days -delete
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement