Created
March 11, 2021 22:56
-
-
Save ozcanzaferayan/446ef6b75702a318511e3ff5f0263476 to your computer and use it in GitHub Desktop.
Tails a file that served on specified URL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tail -f -n 10 server.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment