Skip to content

Instantly share code, notes, and snippets.

@aredridel
Last active January 4, 2016 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aredridel/8633563 to your computer and use it in GitHub Desktop.
Save aredridel/8633563 to your computer and use it in GitHub Desktop.
var fs = require('fs');
function writeTime(){
var lifedata;
var filename = './life.json';
fs.readFile(filename, 'utf8', function (err, data) {
if (err) throw err;
lifedata = JSON.parse(data);
doWrite();
});
function doWrite() {
var d = new Date();
lifedata.time = d.getTime();
fs.writeFile(filename, JSON.stringify(lifedata, null, 4), function(err) {
if(err) {
console.log(err);
} else {
console.log("written");
}
});
}
}
setInterval(writeTime, 120000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment