tail -f logfile.txt
outputs the last 10 lines of logfile.txt, and then continues to output appended data as the file grows.
What\'s the recommended way
The canonical way to do this is with fs.watchFile.
Alternatively, you could just use the node-tail module, which uses fs.watchFile
internally and has already done the work for you. Here is an example of using it straight from the documentation:
Tail = require('tail').Tail;
tail = new Tail("fileToTail");
tail.on("line", function(data) {
console.log(data);
});