Cut off every 7 days

Reply

Join Date: Jun 2008
Posts: 24
Reputation: Aigini is an unknown quantity at this point 
Solved Threads: 0
Aigini Aigini is offline Offline
Newbie Poster

Cut off every 7 days

 
0
  #1
33 Days Ago
Hi,

I am a trainee System Administrator in my company and still a newbie. How do I set the cron job to only show the current week's backup (in the database backup directory) and remove the previous week's backups.

One week would mean Monday to Saturday.

Pls help.

Tqs.
Last edited by Aigini; 33 Days Ago at 3:35 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 12
Reputation: i_tears is an unknown quantity at this point 
Solved Threads: 0
i_tears i_tears is offline Offline
Newbie Poster
 
0
  #2
33 Days Ago
Originally Posted by Aigini View Post
Hi,

I am a trainee System Administrator in my company and still a newbie. How do I set the cron job to only show the current week's backup (in the database backup directory) and remove the previous week's backups.

One week would mean Monday to Saturday.

Pls help.

Tqs.
Hi

First create a script like (removeoldbackup.sh) in that script add these lines.

#!/bin/sh
cd /database_backup_directory/
find . -mtime +7 -exec rm -rf {} \;

exit and save file. Then make that file executable. I hope you know about how to make executable.

Then you can set crontab as per your requirement.


That is...
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 24
Reputation: Aigini is an unknown quantity at this point 
Solved Threads: 0
Aigini Aigini is offline Offline
Newbie Poster
 
0
  #3
33 Days Ago
Where do I put that script? Should it also be in the same directory as the backup script?
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 12
Reputation: i_tears is an unknown quantity at this point 
Solved Threads: 0
i_tears i_tears is offline Offline
Newbie Poster
 
0
  #4
33 Days Ago
Originally Posted by Aigini View Post
Where do I put that script? Should it also be in the same directory as the backup script?
Its your choice place it anywhere like. /home/scripts/databasebackupscripts.sh

Regards
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the *nix Software Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC