The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
format the extracted data kmanivan82 Shell Programming and Scripting 2 10-15-2008 03:38 PM
To send an email with the body content extracted from a file rohit.shetty84 UNIX for Dummies Questions & Answers 3 05-11-2008 11:32 PM
about UNIX? original version? slowchem UNIX for Dummies Questions & Answers 4 12-07-2006 01:25 AM
Original BYTE UNIX Benchmarks (Version 3.11) Neo Linux Benchmarks 0 09-06-2003 03:33 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-14-2008
frankie06 frankie06 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 14
Cool tar: how to preserve atime? (also on extracted version, not just original)

How do I make tar set the correct atime on the extracted version? The option --atime-preserve works just on the original, not on the extracted file.
The extracted files always have current time as atime, which is bad.
  #2 (permalink)  
Old 12-14-2008
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
  
 

Join Date: Dec 2007
Posts: 423
use the -p option when you extract it.
  #3 (permalink)  
Old 12-14-2008
frankie06 frankie06 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 14
Cool

That was quick. Thanks!


Quote:
Originally Posted by frank_rizzo View Post
use the -p option when you extract it.

This does not seem to work though. See below an example where 2 files (with different atimes) are archived and extracted somewhere else. The last line of output shows that the atime was not preserved.

$ ls -lt origin/b*
-rw-r--r-- 1 dsilt2 dsilt2 4 2008-12-15 03:52 origin/bla2
-rw-r--r-- 1 dsilt2 dsilt2 4 2007-07-07 22:22 origin/bla1
$ ls -ltu origin/b*
-rw-r--r-- 1 dsilt2 dsilt2 4 2008-12-15 03:52 origin/bla2
-rw-r--r-- 1 dsilt2 dsilt2 4 2007-07-07 22:22 origin/bla1
$ cd origin/
$ tar --atime-preserve -cvpf archive.tar *
bla1
bla2
$ mv archive.tar ../destination/
$ cd ../destination/
$ tar xvpf archive.tar
bla1
bla2
$ ls -lt b*
-rw-r--r-- 1 dsilt2 dsilt2 4 2008-12-15 03:52 bla2
-rw-r--r-- 1 dsilt2 dsilt2 4 2007-07-07 22:22 bla1
$ ls -ltu b*
-rw-r--r-- 1 dsilt2 dsilt2 4 2008-12-15 04:01 bla1
-rw-r--r-- 1 dsilt2 dsilt2 4 2008-12-15 04:01 bla2
  #4 (permalink)  
Old 12-14-2008
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
  
 

Join Date: Dec 2007
Posts: 423
can you add --atime-preserve when you do the extract?
  #5 (permalink)  
Old 12-14-2008
frankie06 frankie06 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 14
Cool

Quote:
Originally Posted by frank_rizzo View Post
can you add --atime-preserve when you do the extract?
Sure. Same result. Files are as in previous shell log.

$ rm destination/bla*
$ cd destination/
$ tar --atime-preserve -xvpf archive.tar
bla1
bla2
$ ls -lt b*
-rw-r--r-- 1 dsilt2 dsilt2 4 2008-12-15 03:52 bla2
-rw-r--r-- 1 dsilt2 dsilt2 4 2007-07-07 22:22 bla1
$ ls -ltu b*
-rw-r--r-- 1 dsilt2 dsilt2 4 2008-12-15 04:22 bla1
-rw-r--r-- 1 dsilt2 dsilt2 4 2008-12-15 04:22 bla2
  #6 (permalink)  
Old 12-15-2008
frankie06 frankie06 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 14
Quote:
Originally Posted by frankie06 View Post
How do I make tar set the correct atime on the extracted version?
I should add that I don't necessarily have to work with tar, *any* tool that can do it is fine by me, say cpio, scp, and so on. It's just that tar, according to its documentation, at least *seems* able to preserve time and atime (and permissions of course). If someone knows of any other tool that can move files between computers and preserves those 3 things, that's fine by me too.
  #7 (permalink)  
Old 12-15-2008
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 704
Hi.

My reading of this:
Code:
`--atime-preserve'
     Tells `tar' to preserve the access time field in a file's inode
     when reading it.

-- excerpt from info tar
leads me to believe that this on the source side, not on the target side. In other words, tar obtains the inode times, reads the file into the accumulation of the output file, then resets the inode times to the original.

Some filesystems are set not to even record the access times, since it is often of limited value and causes disk activity.

If my supposition is correct, then one could use touch to reset the access times on the target -- tedious, but doable.

Perhaps someone will stop by with a definitive answer ... cheers, drl
Sponsored Links
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0