Jump to content

House Cleaning with crontab


Cowboy Denny
 Share

Recommended Posts

We leverage a linux box (RHEL 7) to store a month worth of F5 ucs files from all 70 of our F5's in the event we need to restore from scratch.  Each file averages around 700M so this can fill up rather quickly if you don't do some house cleaning and remove old files.

This is where leveraging crontab can help.

Here are some examples of house cleaning in the directory where we save our files at which is /home/confback/backups/f5/

++++++++++++++++++++++++++++++++++++++++++++++++++++++
sudo vi /etc/crontab

## This command leaves seven days of .ucs files on the server
0 0 * * * /usr/bin/find /home/confback/backups/f5/ -name "*.ucs" -type f -mtime +30 -exec rm -f {} \;

## This command leaves seven days of .ucs files on the server
0 0 * * * /usr/bin/find /home/confback/backups/f5/ -name "*.ucs" -type f -mtime +7 -exec rm -f {} \;

## This command leaves three days of all files on the server
0 0 * * * root /usr/bin/find /home/confback/backups/f5/ -type f -mtime +1 -exec rm {} +

## This command leaves only today files on the server
5 0 * * * root /usr/bin/find /home/confback/backups/f5/ -type f -mmin -1440 -delete;

## Also had this command which is VERY similar to the first command with slight difference on how the command ends.
0 0 * * * root /usr/bin/find /home/confback/backups/f5/ -type f -mtime +1 -exec rm -rf {} \;
++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...