Posted By

jerryvig on 09/03/11


Tagged

Bash delete unix files


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

zack


Bash Script for Deleting Files X Number of Days Old


 / Published in: Bash
 

This a Bash one-liner script that will automatically delete files older than 14 days in given directory whose name pattern matches the pattern given to find. The script will need to be put on a cron schedule in order to automatically execute the file deletions. The " in the code below should be replaced by the desired number of days.

  1. #!/bin/bash
  2.  
  3. /usr/bin/find /home/content/b/i/n/binaryprojects/html/jerryv0824/backpageEscorts/log_files/ScrapeBackpageLog* -type f -mtime +<X> -exec /bin/rm {} \;

Report this snippet  

You need to login to post a comment.