Find the answer to your Linux question:
Results 1 to 3 of 3
Hello, I'm not an advanced linux user though I've been using for years, here's my question. I'm trying to setup a cron job to backup my websites daily, normally when ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2005
    Posts
    9

    how to use date command in filenaming for cron job?


    Hello,
    I'm not an advanced linux user though I've been using for years, here's my question.

    I'm trying to setup a cron job to backup my websites daily, normally when I manually do this I include the date in the name of the created file, like: website-12-10-09.tar.gz

    now I'm wondering if there is a way to dynamically include the date, something like:


    tar -zcvf websites[date '+-%d-%m-%y'].tar.gz websites/


    any ideas would be great!
    cheers,
    -Ken

  2. #2
    Linux Newbie
    Join Date
    Mar 2009
    Posts
    228
    You're real close. It would be:

    Code:
    tar -zcvf websites`date '+-%d-%m-%y'`.tar.gz websites/

  3. #3
    Just Joined!
    Join Date
    Dec 2005
    Posts
    9
    hehe,, yes I knew it was something simple but wasn't sure of the syntax. but that did the trick!

    much appreciated!

Posting Permissions

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