Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a script to backup some directories:

tar cjf /backup-`date +\%m-\%d-\%Y`.tar.bz2 mydir >> /dev/null 2>&1

At the end of the process, a "ls -al" show something like:

-rwxr-xr-x 1 my my    719110144 May 29  2000 backup-08-02-2013.tar.bz2

Notice the year: 2000. Archive was made in 2013… What's the problem and how to solve it?

Thanks for your help.

share|improve this question
    
Have you checked the date & time of the computer (using date)? :-) –  Cristian Ciupitu Aug 30 '13 at 0:21
    
@CristianCiupitu: The filename tells us the output from date +%m-%d-%Y. –  Scott Aug 30 '13 at 1:20

1 Answer 1

up vote 1 down vote accepted

If your archive is being written to a network file system (like NFS or AFS), then make sure the file server has the right date set, as the timestamp of the newly-created file will be determined by the file server's clock. If you can't fix things on the server side, then you'll most likely have to correct the timestamp manually after file creation.

share|improve this answer
    
Thanks, you're right. The NAS date was'nt correct. –  Greg Aug 30 '13 at 6:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.