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,

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...

Where do I put that script? Should it also be in the same directory as the backup script?

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

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.