node.js - Cronjobs and Nodejs -


im trying create log file every day using cronjobs. whenever restart node server create new log file same otherwise writes log in same file. please help

take minute read this: https://www.npmjs.com/package/cron
, this: https://www.npmjs.com/package/moment

function startlogger() {     var name = (require('moment')()).format('yyyy-mm-dd')     var path = ('~/' + name);      // if (path) doesn't exist, create it. (do code)      // write end of existent or created file:     (require('fs')).appendfile(path, 'your log line or multiple lines', function (err) {       if (err) throw err;       console.log('log saved successfully!');     }); } 

ps: not recommend use require inside (), did because i'm without time hope understand , make own code.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -