Skip to content

Instantly share code, notes, and snippets.

@ozcanzaferayan
Created March 11, 2021 22:56
Show Gist options
  • Save ozcanzaferayan/446ef6b75702a318511e3ff5f0263476 to your computer and use it in GitHub Desktop.
Save ozcanzaferayan/446ef6b75702a318511e3ff5f0263476 to your computer and use it in GitHub Desktop.
Tails a file that served on specified URL.
var http = require('http');
var fs = require('fs');
var path = require('path');
const URL = "http://blabla/server.log";
const FILE = "server.log";
var download = function(url, dest, cb) {
var file = fs.createWriteStream(path.join(__dirname, dest));
http.get(url, function(response) {
response.pipe(file);
file.on('finish', function() {
file.close(cb);
});
});
}
setInterval(() => {
download(URL, FILE);
console.log("downloaded");
}, 15 * 1000);
tail -f -n 10 server.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment