Posted By

viatropos on 08/16/10


Tagged

unix log tail nodejs


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

capsella


Tail Log Output with Node.js


 / Published in: JavaScript
 

URL: tail-log-output-with-node-js

  1. // http://nodejs.org/api.html#_child_processes
  2. var sys = require('sys')
  3. var spawn = require('child_process').spawn;
  4. var filename = process.ARGV[2];
  5.  
  6. if (!filename)
  7. return sys.puts("Usage: node <server.js> <filename>");
  8.  
  9. var tail = spawn("tail", ["-f", filename]);
  10. sys.puts("start tailing");
  11.  
  12. tail.stdout.on("data", function (data) {
  13. sys.puts(data);
  14. });
  15.  
  16. // node tail.js development.log

Report this snippet  

You need to login to post a comment.