java - Transfer portion of large file from server via SSH -
for our applications, log files on several different remote servers depending on environment. although rollover daily, envs, logs can grow large (typical high-traffic environment has logs reach 10 gb daily).
basically i'm trying achieve functionality similar unix less
command jump last line of file , read newest portions.
i started jsch
in java worked small files, skip end minus set number of bytes , create new file last portion of log. code looks this:
session session = createjschsession(user, pass, host, port); channelsftp sftpchannel = createsftpchannel(session); long filesize = getfilesize(sftpchannel, path); inputstream in = sftpchannel.get("/path/to/file/hello.log"); in.skip(filesize - bytestoread);
however larger files, execution time no better if i'd transferred file whole. after timing determined skip
method culprit, seems call in.read()
n times.
the question is, how transfer small chunk of text file remote server? i'm not dead-set on using java, kind of script work.
Comments
Post a Comment