Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linux script 2

Status
Not open for further replies.

kzn

MIS
Jan 28, 2005
209
GB
Hi I am running Centos 6.4 and would appreciate any pointers with regards to the following.
I have set up a cron job to run a script file every day. The script is as follows: mysqldump -u root -ptest123 conversis >> /root/backup.txt

Basically all I am trying to achieve is for a backup to be created daily but I do not want it to over write the previous days back up. In an ideal situation the following would happen:
backup1.txt
backup2.txt
.
.
backup30.txt

and then it would start the cycle again and over write backup1.txt once it reached backup30.txt.

Any ideas or pointers appreciated.

Thank you,
 
Hi

If that 1..~30 number can match the current month's day, then just use [tt]date[/tt] :
Code:
33 3 * * * mysqldump -u root -ptest123 conversis >> "/root/backup$( date +'%d' ).txt"
( Note that I usually forget ( this time I remembered just because the previous forgetting was yesterday in thread822-1711114 ) that [url ]percent sign ( % ) has special meaning[/url] in certain Cron implementation. You may have to escape it. My Dillon's Cron needs no such escaping. )


Feherke.
feherke.github.io
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top