Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 13 of 13
actually i am writing a script, i thought i mentioned that before here is a segment of it Code: DELETED basically it calls vmstat every 5 seconds in 1 min ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Just Joined!
    Join Date
    May 2009
    Posts
    35

    actually i am writing a script, i thought i mentioned that before

    here is a segment of it

    Code:
    DELETED
    basically it calls vmstat every 5 seconds in 1 min intervals for "duration" mins, and compresses the data gathered into a tar.bz2 file, now what i am doing right now is creating a file, adding it to a tarball, then deleting it, but this seems like an overkill, why not just add it from the get go to the tarball??

    any ideas??

  2. #12
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    The only -very ugly and hackish idea- that I can think of is to exploit one of the capabilities of gzunzip/tar. It has the capability to ignore trailing garbage on an archive, so you could theoretically append (>>) the vmstat uncompressed at the end of the tar file and you will still be able to uncompress it without any trouble at all.

    An entirely different matter would be how to recover cleanly that info that was added at the end of the file. You could insert a given signature at the end of the tarball before appending the real data.

    Code:
    echo "myMARKER" >> file.tar.gz
    vmstat >> file.tar.gz
    sed -n '/myMARKER/,/*/p' file.tar.gz

    Nothing guarantees you that "myMARKER" is not going to appear throughout the archive though. As I said, this is extremely hackish. It's the only thing I can think of if you must use standard tar. Of course it would be possible to patch tar so you can get input from stdin and give it a file name on the fly. No idea how complex that would be.

  3. #13
    Just Joined!
    Join Date
    May 2009
    Posts
    35
    Quote Originally Posted by i92guboj View Post
    The only -very ugly and hackish idea- that I can think of is to exploit one of the capabilities of gzunzip/tar. It has the capability to ignore trailing garbage on an archive, so you could theoretically append (>>) the vmstat uncompressed at the end of the tar file and you will still be able to uncompress it without any trouble at all.

    An entirely different matter would be how to recover cleanly that info that was added at the end of the file. You could insert a given signature at the end of the tarball before appending the real data.

    Code:
    echo "myMARKER" >> file.tar.gz
    vmstat >> file.tar.gz
    sed -n '/myMARKER/,/*/p' file.tar.gz

    Nothing guarantees you that "myMARKER" is not going to appear throughout the archive though. As I said, this is extremely hackish. It's the only thing I can think of if you must use standard tar. Of course it would be possible to patch tar so you can get input from stdin and give it a file name on the fly. No idea how complex that would be.
    na forget it, its our first script assignment and i doubt my lecturer meant us to do this, either way i will ask him just to be sure

Page 2 of 2 FirstFirst 1 2

Posting Permissions

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