How to process series of files once transfer complete

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












What I have



I have 2 servers. Lets call them sen.der and recei.ver.



Sender generates files; these files can range in size from a 20Kb to 30 Gb.



I've written a script that checks to see how big the file is once it has been generated and if it's smaller than 10Mb, sends the file to recei.ver via SFTP. Otherwise, if it's greater than 10Mb, splits it up into 10Mb chunks and then sends them off to recei.ver via SFTP.



The sending time is obviously determined by the file size and the line-speed. That linespeed may be as low as 100Kbps meaning that it could theoretically take as much as 11 hours to transfer the biggest file.



What I Need



What I'm trying to do is get recei.ver to automatically cat the files back into one big one (and run a few extra errands like untar, send notification email, etc).



What I could do



I could try using inotifywait with the -m option, and then check the file size of the files being written and then cat the lot, when the last file that was created is less than 10,485,760 bytes.



I could then cat the chunks, and test the tar with a tar tf <filename>; echo $?



Is there a better way?



It would probably work... But doesn't seem elegant. Is there a better way to do this?










share|improve this question

























    up vote
    0
    down vote

    favorite












    What I have



    I have 2 servers. Lets call them sen.der and recei.ver.



    Sender generates files; these files can range in size from a 20Kb to 30 Gb.



    I've written a script that checks to see how big the file is once it has been generated and if it's smaller than 10Mb, sends the file to recei.ver via SFTP. Otherwise, if it's greater than 10Mb, splits it up into 10Mb chunks and then sends them off to recei.ver via SFTP.



    The sending time is obviously determined by the file size and the line-speed. That linespeed may be as low as 100Kbps meaning that it could theoretically take as much as 11 hours to transfer the biggest file.



    What I Need



    What I'm trying to do is get recei.ver to automatically cat the files back into one big one (and run a few extra errands like untar, send notification email, etc).



    What I could do



    I could try using inotifywait with the -m option, and then check the file size of the files being written and then cat the lot, when the last file that was created is less than 10,485,760 bytes.



    I could then cat the chunks, and test the tar with a tar tf <filename>; echo $?



    Is there a better way?



    It would probably work... But doesn't seem elegant. Is there a better way to do this?










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      What I have



      I have 2 servers. Lets call them sen.der and recei.ver.



      Sender generates files; these files can range in size from a 20Kb to 30 Gb.



      I've written a script that checks to see how big the file is once it has been generated and if it's smaller than 10Mb, sends the file to recei.ver via SFTP. Otherwise, if it's greater than 10Mb, splits it up into 10Mb chunks and then sends them off to recei.ver via SFTP.



      The sending time is obviously determined by the file size and the line-speed. That linespeed may be as low as 100Kbps meaning that it could theoretically take as much as 11 hours to transfer the biggest file.



      What I Need



      What I'm trying to do is get recei.ver to automatically cat the files back into one big one (and run a few extra errands like untar, send notification email, etc).



      What I could do



      I could try using inotifywait with the -m option, and then check the file size of the files being written and then cat the lot, when the last file that was created is less than 10,485,760 bytes.



      I could then cat the chunks, and test the tar with a tar tf <filename>; echo $?



      Is there a better way?



      It would probably work... But doesn't seem elegant. Is there a better way to do this?










      share|improve this question













      What I have



      I have 2 servers. Lets call them sen.der and recei.ver.



      Sender generates files; these files can range in size from a 20Kb to 30 Gb.



      I've written a script that checks to see how big the file is once it has been generated and if it's smaller than 10Mb, sends the file to recei.ver via SFTP. Otherwise, if it's greater than 10Mb, splits it up into 10Mb chunks and then sends them off to recei.ver via SFTP.



      The sending time is obviously determined by the file size and the line-speed. That linespeed may be as low as 100Kbps meaning that it could theoretically take as much as 11 hours to transfer the biggest file.



      What I Need



      What I'm trying to do is get recei.ver to automatically cat the files back into one big one (and run a few extra errands like untar, send notification email, etc).



      What I could do



      I could try using inotifywait with the -m option, and then check the file size of the files being written and then cat the lot, when the last file that was created is less than 10,485,760 bytes.



      I could then cat the chunks, and test the tar with a tar tf <filename>; echo $?



      Is there a better way?



      It would probably work... But doesn't seem elegant. Is there a better way to do this?







      bash tar split inotify






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 31 at 9:41









      Jim

      9313




      9313




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          Using the size of a partial file as an implicit end marker may be brittle. Much better would be to send the parts first and then send a control file which lists the parts (maybe with sha256 checksums to detect transfer problems) so that the receiving program can check whether all parts have been transmitted and start reassembling only then.






          share|improve this answer




















          • Worth a shot. (about the control file). I've been including the checksum in the tarball, but I see your point of using it instead of trying to check the integrity of the file with a tar tf
            – Jim
            Aug 31 at 12:08










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f465976%2fhow-to-process-series-of-files-once-transfer-complete%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote













          Using the size of a partial file as an implicit end marker may be brittle. Much better would be to send the parts first and then send a control file which lists the parts (maybe with sha256 checksums to detect transfer problems) so that the receiving program can check whether all parts have been transmitted and start reassembling only then.






          share|improve this answer




















          • Worth a shot. (about the control file). I've been including the checksum in the tarball, but I see your point of using it instead of trying to check the integrity of the file with a tar tf
            – Jim
            Aug 31 at 12:08














          up vote
          1
          down vote













          Using the size of a partial file as an implicit end marker may be brittle. Much better would be to send the parts first and then send a control file which lists the parts (maybe with sha256 checksums to detect transfer problems) so that the receiving program can check whether all parts have been transmitted and start reassembling only then.






          share|improve this answer




















          • Worth a shot. (about the control file). I've been including the checksum in the tarball, but I see your point of using it instead of trying to check the integrity of the file with a tar tf
            – Jim
            Aug 31 at 12:08












          up vote
          1
          down vote










          up vote
          1
          down vote









          Using the size of a partial file as an implicit end marker may be brittle. Much better would be to send the parts first and then send a control file which lists the parts (maybe with sha256 checksums to detect transfer problems) so that the receiving program can check whether all parts have been transmitted and start reassembling only then.






          share|improve this answer












          Using the size of a partial file as an implicit end marker may be brittle. Much better would be to send the parts first and then send a control file which lists the parts (maybe with sha256 checksums to detect transfer problems) so that the receiving program can check whether all parts have been transmitted and start reassembling only then.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 31 at 11:07









          Hans-Martin Mosner

          1,22548




          1,22548











          • Worth a shot. (about the control file). I've been including the checksum in the tarball, but I see your point of using it instead of trying to check the integrity of the file with a tar tf
            – Jim
            Aug 31 at 12:08
















          • Worth a shot. (about the control file). I've been including the checksum in the tarball, but I see your point of using it instead of trying to check the integrity of the file with a tar tf
            – Jim
            Aug 31 at 12:08















          Worth a shot. (about the control file). I've been including the checksum in the tarball, but I see your point of using it instead of trying to check the integrity of the file with a tar tf
          – Jim
          Aug 31 at 12:08




          Worth a shot. (about the control file). I've been including the checksum in the tarball, but I see your point of using it instead of trying to check the integrity of the file with a tar tf
          – Jim
          Aug 31 at 12:08

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f465976%2fhow-to-process-series-of-files-once-transfer-complete%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay