Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts

    Question shell date scripting?

    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;
    PHP Code:
    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;

    PHP Code:
    date -"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!

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    scratch that, I've got it;

    my test command
    PHP Code:
    touch test`date '+-%d-%m-%y' -d '+5 days ago'`.txt 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •