Cut off every 7 days

Reply

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

Cut off every 7 days

 
0
  #1
Oct 27th, 2009
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; Oct 27th, 2009 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
Oct 27th, 2009
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: 25
Reputation: Aigini is an unknown quantity at this point 
Solved Threads: 0
Aigini Aigini is offline Offline
Light Poster
 
0
  #3
Oct 27th, 2009
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
Oct 27th, 2009
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  
Join Date: Jun 2004
Posts: 192
Reputation: Toba is an unknown quantity at this point 
Solved Threads: 5
Toba's Avatar
Toba Toba is offline Offline
Junior Poster
 
0
  #5
12 Days Ago
Oh no! You're unqualified for your job, which is basically googling technician. Quick, post "How I sysadmin a com-pu-tar!?!?" to a forum until someone gives you the answer!
what? WHAT?
Reply With Quote Quick reply to this message  
Reply

Message:



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



Tag cloud for *nix Software
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC