Preserving timestamps when extracting .tgz logs












1















I have multiple .tgz kernel-panic logs that I must extract from one file. The timestamps for these .tgz files are important. Whenever I use the following:
tar - zvxf paniclogs.tgz



-rwxrwxrwx 1 root root   22359 Feb 22 15:03 kernel-panic-20190213020406-3.tgz
-rwxrwxrwx 1 root root 22971 Feb 22 15:03 kernel-panic-20190213020844-2.tgz
-rwxrwxrwx 1 root root 28344 Feb 22 15:03 kernel-panic-20190213101549-1.tgz
-rwxrwxrwx 1 root root 30683 Feb 22 15:03 kernel-panic-20190213154050-0.tgz


It extracts the logs but changes the timestamps to the date and time when I extracted them. This is not the case when I use Cygwin. I know there must be a way to extract these logs and preserve the time stamps. Can you please assist? Thank you.










share|improve this question



























    1















    I have multiple .tgz kernel-panic logs that I must extract from one file. The timestamps for these .tgz files are important. Whenever I use the following:
    tar - zvxf paniclogs.tgz



    -rwxrwxrwx 1 root root   22359 Feb 22 15:03 kernel-panic-20190213020406-3.tgz
    -rwxrwxrwx 1 root root 22971 Feb 22 15:03 kernel-panic-20190213020844-2.tgz
    -rwxrwxrwx 1 root root 28344 Feb 22 15:03 kernel-panic-20190213101549-1.tgz
    -rwxrwxrwx 1 root root 30683 Feb 22 15:03 kernel-panic-20190213154050-0.tgz


    It extracts the logs but changes the timestamps to the date and time when I extracted them. This is not the case when I use Cygwin. I know there must be a way to extract these logs and preserve the time stamps. Can you please assist? Thank you.










    share|improve this question

























      1












      1








      1








      I have multiple .tgz kernel-panic logs that I must extract from one file. The timestamps for these .tgz files are important. Whenever I use the following:
      tar - zvxf paniclogs.tgz



      -rwxrwxrwx 1 root root   22359 Feb 22 15:03 kernel-panic-20190213020406-3.tgz
      -rwxrwxrwx 1 root root 22971 Feb 22 15:03 kernel-panic-20190213020844-2.tgz
      -rwxrwxrwx 1 root root 28344 Feb 22 15:03 kernel-panic-20190213101549-1.tgz
      -rwxrwxrwx 1 root root 30683 Feb 22 15:03 kernel-panic-20190213154050-0.tgz


      It extracts the logs but changes the timestamps to the date and time when I extracted them. This is not the case when I use Cygwin. I know there must be a way to extract these logs and preserve the time stamps. Can you please assist? Thank you.










      share|improve this question














      I have multiple .tgz kernel-panic logs that I must extract from one file. The timestamps for these .tgz files are important. Whenever I use the following:
      tar - zvxf paniclogs.tgz



      -rwxrwxrwx 1 root root   22359 Feb 22 15:03 kernel-panic-20190213020406-3.tgz
      -rwxrwxrwx 1 root root 22971 Feb 22 15:03 kernel-panic-20190213020844-2.tgz
      -rwxrwxrwx 1 root root 28344 Feb 22 15:03 kernel-panic-20190213101549-1.tgz
      -rwxrwxrwx 1 root root 30683 Feb 22 15:03 kernel-panic-20190213154050-0.tgz


      It extracts the logs but changes the timestamps to the date and time when I extracted them. This is not the case when I use Cygwin. I know there must be a way to extract these logs and preserve the time stamps. Can you please assist? Thank you.







      tar






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 22 at 22:06









      Ryan GildersleeveRyan Gildersleeve

      61




      61






















          1 Answer
          1






          active

          oldest

          votes


















          0














          This cannot be done with GNU tar. However there is a lesser known utility star, developed by Jörg Schilling, which will accomplish exactly what you are after. I will demonstrate how this works.



          First we can examine a single file within a test tgz archive and demonstrate its timestamp, which I have highlighted below to make the terminal output perfectly clear:



          andrew@ilium$ tar -tv --full-time -f test.tgz mp3enc31/readme.txt
          -rw-r--r-- sir/inel 937 1998-11-06 00:28:41 mp3enc31/readme.txt
          ^^^^^^^^^^


          As you have found when you extract this file in the customary manner with tar the access time (and the change time) is altered. Again I have altered the terminal output to easily show this:



          andrew@ilium~$ tar -xf test.tgz mp3enc31/readme.txt
          andrew@ilium~$ stat mp3enc31/readme.txt
          File: readme.txt
          Size: 937 Blocks: 8 IO Block: 4096 regular file
          Device: 801h/2049d Inode: 56885505 Links: 1
          Access: (0644/-rw-r--r--) Uid: ( 1000/ andrew) Gid: ( 100/ users)
          Access: 2019-02-23 17:13:55.385500219 +1100 <--------------------
          Modify: 1998-11-06 00:28:41.000000000 +1100
          Change: 2019-02-23 17:13:55.385500219 +1100 <--------------------
          Birth: -
          andrew@ilium~$


          However if we use the star utility as sudo, (note that sudo is required for the ctime modification) you will see that all access times are preserved:



          andrew@ilium~$ sudo star -xza -ctime < test.tgz mp3enc31/readme.txt
          star: 62 blocks + 0 bytes (total of 634880 bytes = 620.00k).
          andrew@ilium~$ stat mp3enc31/readme.txt
          File: readme.txt
          Size: 937 Blocks: 8 IO Block: 4096 regular file
          Device: 801h/2049d Inode: 59377688 Links: 1
          Access: (0644/-rw-r--r--) Uid: (30076/ UNKNOWN) Gid: (30000/ UNKNOWN)
          Access: 1998-11-06 00:28:41.000000000 +1100 <--------------------
          Modify: 1998-11-06 00:28:41.000000000 +1100
          Change: 1998-11-06 00:28:41.000000000 +1100 <--------------------
          Birth: -
          andrew@ilium~$


          The star man pages advise some caution with the -ctime option as it can confuse cron, the news system and even slow the system clock. So just be a little careful!



          References:





          • man pages for star: Documentation for all of the options used above and demonstration of the many other options available.






          share|improve this answer


























          • Thank you. I really appreciate the time and effort you put into your answer. I was really hoping for the same results I get when I use Cygwin to perform the same action. Do you have any idea as to why Cygwin can accomplish this using tar -xf by Ubuntu cannot?

            – Ryan Gildersleeve
            Feb 24 at 23:12











          • @RyanGildersleeve Unfortunately I am not familiar at all with Cygwin :(

            – andrew.46
            Feb 25 at 0:57











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1120494%2fpreserving-timestamps-when-extracting-tgz-logs%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          This cannot be done with GNU tar. However there is a lesser known utility star, developed by Jörg Schilling, which will accomplish exactly what you are after. I will demonstrate how this works.



          First we can examine a single file within a test tgz archive and demonstrate its timestamp, which I have highlighted below to make the terminal output perfectly clear:



          andrew@ilium$ tar -tv --full-time -f test.tgz mp3enc31/readme.txt
          -rw-r--r-- sir/inel 937 1998-11-06 00:28:41 mp3enc31/readme.txt
          ^^^^^^^^^^


          As you have found when you extract this file in the customary manner with tar the access time (and the change time) is altered. Again I have altered the terminal output to easily show this:



          andrew@ilium~$ tar -xf test.tgz mp3enc31/readme.txt
          andrew@ilium~$ stat mp3enc31/readme.txt
          File: readme.txt
          Size: 937 Blocks: 8 IO Block: 4096 regular file
          Device: 801h/2049d Inode: 56885505 Links: 1
          Access: (0644/-rw-r--r--) Uid: ( 1000/ andrew) Gid: ( 100/ users)
          Access: 2019-02-23 17:13:55.385500219 +1100 <--------------------
          Modify: 1998-11-06 00:28:41.000000000 +1100
          Change: 2019-02-23 17:13:55.385500219 +1100 <--------------------
          Birth: -
          andrew@ilium~$


          However if we use the star utility as sudo, (note that sudo is required for the ctime modification) you will see that all access times are preserved:



          andrew@ilium~$ sudo star -xza -ctime < test.tgz mp3enc31/readme.txt
          star: 62 blocks + 0 bytes (total of 634880 bytes = 620.00k).
          andrew@ilium~$ stat mp3enc31/readme.txt
          File: readme.txt
          Size: 937 Blocks: 8 IO Block: 4096 regular file
          Device: 801h/2049d Inode: 59377688 Links: 1
          Access: (0644/-rw-r--r--) Uid: (30076/ UNKNOWN) Gid: (30000/ UNKNOWN)
          Access: 1998-11-06 00:28:41.000000000 +1100 <--------------------
          Modify: 1998-11-06 00:28:41.000000000 +1100
          Change: 1998-11-06 00:28:41.000000000 +1100 <--------------------
          Birth: -
          andrew@ilium~$


          The star man pages advise some caution with the -ctime option as it can confuse cron, the news system and even slow the system clock. So just be a little careful!



          References:





          • man pages for star: Documentation for all of the options used above and demonstration of the many other options available.






          share|improve this answer


























          • Thank you. I really appreciate the time and effort you put into your answer. I was really hoping for the same results I get when I use Cygwin to perform the same action. Do you have any idea as to why Cygwin can accomplish this using tar -xf by Ubuntu cannot?

            – Ryan Gildersleeve
            Feb 24 at 23:12











          • @RyanGildersleeve Unfortunately I am not familiar at all with Cygwin :(

            – andrew.46
            Feb 25 at 0:57
















          0














          This cannot be done with GNU tar. However there is a lesser known utility star, developed by Jörg Schilling, which will accomplish exactly what you are after. I will demonstrate how this works.



          First we can examine a single file within a test tgz archive and demonstrate its timestamp, which I have highlighted below to make the terminal output perfectly clear:



          andrew@ilium$ tar -tv --full-time -f test.tgz mp3enc31/readme.txt
          -rw-r--r-- sir/inel 937 1998-11-06 00:28:41 mp3enc31/readme.txt
          ^^^^^^^^^^


          As you have found when you extract this file in the customary manner with tar the access time (and the change time) is altered. Again I have altered the terminal output to easily show this:



          andrew@ilium~$ tar -xf test.tgz mp3enc31/readme.txt
          andrew@ilium~$ stat mp3enc31/readme.txt
          File: readme.txt
          Size: 937 Blocks: 8 IO Block: 4096 regular file
          Device: 801h/2049d Inode: 56885505 Links: 1
          Access: (0644/-rw-r--r--) Uid: ( 1000/ andrew) Gid: ( 100/ users)
          Access: 2019-02-23 17:13:55.385500219 +1100 <--------------------
          Modify: 1998-11-06 00:28:41.000000000 +1100
          Change: 2019-02-23 17:13:55.385500219 +1100 <--------------------
          Birth: -
          andrew@ilium~$


          However if we use the star utility as sudo, (note that sudo is required for the ctime modification) you will see that all access times are preserved:



          andrew@ilium~$ sudo star -xza -ctime < test.tgz mp3enc31/readme.txt
          star: 62 blocks + 0 bytes (total of 634880 bytes = 620.00k).
          andrew@ilium~$ stat mp3enc31/readme.txt
          File: readme.txt
          Size: 937 Blocks: 8 IO Block: 4096 regular file
          Device: 801h/2049d Inode: 59377688 Links: 1
          Access: (0644/-rw-r--r--) Uid: (30076/ UNKNOWN) Gid: (30000/ UNKNOWN)
          Access: 1998-11-06 00:28:41.000000000 +1100 <--------------------
          Modify: 1998-11-06 00:28:41.000000000 +1100
          Change: 1998-11-06 00:28:41.000000000 +1100 <--------------------
          Birth: -
          andrew@ilium~$


          The star man pages advise some caution with the -ctime option as it can confuse cron, the news system and even slow the system clock. So just be a little careful!



          References:





          • man pages for star: Documentation for all of the options used above and demonstration of the many other options available.






          share|improve this answer


























          • Thank you. I really appreciate the time and effort you put into your answer. I was really hoping for the same results I get when I use Cygwin to perform the same action. Do you have any idea as to why Cygwin can accomplish this using tar -xf by Ubuntu cannot?

            – Ryan Gildersleeve
            Feb 24 at 23:12











          • @RyanGildersleeve Unfortunately I am not familiar at all with Cygwin :(

            – andrew.46
            Feb 25 at 0:57














          0












          0








          0







          This cannot be done with GNU tar. However there is a lesser known utility star, developed by Jörg Schilling, which will accomplish exactly what you are after. I will demonstrate how this works.



          First we can examine a single file within a test tgz archive and demonstrate its timestamp, which I have highlighted below to make the terminal output perfectly clear:



          andrew@ilium$ tar -tv --full-time -f test.tgz mp3enc31/readme.txt
          -rw-r--r-- sir/inel 937 1998-11-06 00:28:41 mp3enc31/readme.txt
          ^^^^^^^^^^


          As you have found when you extract this file in the customary manner with tar the access time (and the change time) is altered. Again I have altered the terminal output to easily show this:



          andrew@ilium~$ tar -xf test.tgz mp3enc31/readme.txt
          andrew@ilium~$ stat mp3enc31/readme.txt
          File: readme.txt
          Size: 937 Blocks: 8 IO Block: 4096 regular file
          Device: 801h/2049d Inode: 56885505 Links: 1
          Access: (0644/-rw-r--r--) Uid: ( 1000/ andrew) Gid: ( 100/ users)
          Access: 2019-02-23 17:13:55.385500219 +1100 <--------------------
          Modify: 1998-11-06 00:28:41.000000000 +1100
          Change: 2019-02-23 17:13:55.385500219 +1100 <--------------------
          Birth: -
          andrew@ilium~$


          However if we use the star utility as sudo, (note that sudo is required for the ctime modification) you will see that all access times are preserved:



          andrew@ilium~$ sudo star -xza -ctime < test.tgz mp3enc31/readme.txt
          star: 62 blocks + 0 bytes (total of 634880 bytes = 620.00k).
          andrew@ilium~$ stat mp3enc31/readme.txt
          File: readme.txt
          Size: 937 Blocks: 8 IO Block: 4096 regular file
          Device: 801h/2049d Inode: 59377688 Links: 1
          Access: (0644/-rw-r--r--) Uid: (30076/ UNKNOWN) Gid: (30000/ UNKNOWN)
          Access: 1998-11-06 00:28:41.000000000 +1100 <--------------------
          Modify: 1998-11-06 00:28:41.000000000 +1100
          Change: 1998-11-06 00:28:41.000000000 +1100 <--------------------
          Birth: -
          andrew@ilium~$


          The star man pages advise some caution with the -ctime option as it can confuse cron, the news system and even slow the system clock. So just be a little careful!



          References:





          • man pages for star: Documentation for all of the options used above and demonstration of the many other options available.






          share|improve this answer















          This cannot be done with GNU tar. However there is a lesser known utility star, developed by Jörg Schilling, which will accomplish exactly what you are after. I will demonstrate how this works.



          First we can examine a single file within a test tgz archive and demonstrate its timestamp, which I have highlighted below to make the terminal output perfectly clear:



          andrew@ilium$ tar -tv --full-time -f test.tgz mp3enc31/readme.txt
          -rw-r--r-- sir/inel 937 1998-11-06 00:28:41 mp3enc31/readme.txt
          ^^^^^^^^^^


          As you have found when you extract this file in the customary manner with tar the access time (and the change time) is altered. Again I have altered the terminal output to easily show this:



          andrew@ilium~$ tar -xf test.tgz mp3enc31/readme.txt
          andrew@ilium~$ stat mp3enc31/readme.txt
          File: readme.txt
          Size: 937 Blocks: 8 IO Block: 4096 regular file
          Device: 801h/2049d Inode: 56885505 Links: 1
          Access: (0644/-rw-r--r--) Uid: ( 1000/ andrew) Gid: ( 100/ users)
          Access: 2019-02-23 17:13:55.385500219 +1100 <--------------------
          Modify: 1998-11-06 00:28:41.000000000 +1100
          Change: 2019-02-23 17:13:55.385500219 +1100 <--------------------
          Birth: -
          andrew@ilium~$


          However if we use the star utility as sudo, (note that sudo is required for the ctime modification) you will see that all access times are preserved:



          andrew@ilium~$ sudo star -xza -ctime < test.tgz mp3enc31/readme.txt
          star: 62 blocks + 0 bytes (total of 634880 bytes = 620.00k).
          andrew@ilium~$ stat mp3enc31/readme.txt
          File: readme.txt
          Size: 937 Blocks: 8 IO Block: 4096 regular file
          Device: 801h/2049d Inode: 59377688 Links: 1
          Access: (0644/-rw-r--r--) Uid: (30076/ UNKNOWN) Gid: (30000/ UNKNOWN)
          Access: 1998-11-06 00:28:41.000000000 +1100 <--------------------
          Modify: 1998-11-06 00:28:41.000000000 +1100
          Change: 1998-11-06 00:28:41.000000000 +1100 <--------------------
          Birth: -
          andrew@ilium~$


          The star man pages advise some caution with the -ctime option as it can confuse cron, the news system and even slow the system clock. So just be a little careful!



          References:





          • man pages for star: Documentation for all of the options used above and demonstration of the many other options available.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 7 at 23:40

























          answered Feb 23 at 6:30









          andrew.46andrew.46

          22.2k1470150




          22.2k1470150













          • Thank you. I really appreciate the time and effort you put into your answer. I was really hoping for the same results I get when I use Cygwin to perform the same action. Do you have any idea as to why Cygwin can accomplish this using tar -xf by Ubuntu cannot?

            – Ryan Gildersleeve
            Feb 24 at 23:12











          • @RyanGildersleeve Unfortunately I am not familiar at all with Cygwin :(

            – andrew.46
            Feb 25 at 0:57



















          • Thank you. I really appreciate the time and effort you put into your answer. I was really hoping for the same results I get when I use Cygwin to perform the same action. Do you have any idea as to why Cygwin can accomplish this using tar -xf by Ubuntu cannot?

            – Ryan Gildersleeve
            Feb 24 at 23:12











          • @RyanGildersleeve Unfortunately I am not familiar at all with Cygwin :(

            – andrew.46
            Feb 25 at 0:57

















          Thank you. I really appreciate the time and effort you put into your answer. I was really hoping for the same results I get when I use Cygwin to perform the same action. Do you have any idea as to why Cygwin can accomplish this using tar -xf by Ubuntu cannot?

          – Ryan Gildersleeve
          Feb 24 at 23:12





          Thank you. I really appreciate the time and effort you put into your answer. I was really hoping for the same results I get when I use Cygwin to perform the same action. Do you have any idea as to why Cygwin can accomplish this using tar -xf by Ubuntu cannot?

          – Ryan Gildersleeve
          Feb 24 at 23:12













          @RyanGildersleeve Unfortunately I am not familiar at all with Cygwin :(

          – andrew.46
          Feb 25 at 0:57





          @RyanGildersleeve Unfortunately I am not familiar at all with Cygwin :(

          – andrew.46
          Feb 25 at 0:57


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1120494%2fpreserving-timestamps-when-extracting-tgz-logs%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

          Mangá

           ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕