Skip to content

Instantly share code, notes, and snippets.

@hoanga
Created November 25, 2009 04:51
Show Gist options
  • Save hoanga/242487 to your computer and use it in GitHub Desktop.
Save hoanga/242487 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/node
// Program Name: watchfile.js
// Purpose: Monitor a set of files given on the command-line
// Usage: ./watchfile.js /tmp/foo /tmp/bar
// Output: 2009-11-25T04:50:44Z|/tmp/foo
var sys = require('sys');
process.ARGV.forEach(function (f) {
// Don't monitor ourself
if (f !== __filename) {
sys.puts("monitoring " + f);
process.watchFile(f, function () {
var rightNow = new Date();
sys.puts(rightNow.toJSON() + '|' + f);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment