...

View Full Version : shell date scripting?



angst
05-24-2011, 02:18 PM
hello,

i run a simple command line to make backups of sites on my server and move them to another directly which gets backed up to an external drive.

my command;


tar -zcvf /home/sites/backups/MySite`date '+-%d-%m-%y'`.tar.gz /home/sites/MySite/


now what I need to do is remove backups older then 5 days. i see that in the shell I can do a date sub like this;


date -d "5 days ago"

but how can I format the result of this to be the same as the format above? ( %d-%m-%y )?
I can't seem to combine the new functions.

any help would be great!

angst
05-24-2011, 02:35 PM
scratch that, I've got it;

my test command


touch test`date '+-%d-%m-%y' -d '+5 days ago'`.txt



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum