title: Setting a timer in Node.js
body: <p>I need to run code in Node.js every 24 hours. I came across a function called <code>setTimeout</code>. Below is my code snippet </p>
  
  <pre><code>var et = require('elementtree');
  var XML = et.XML;
  var ElementTree = et.ElementTree;
  var element = et.Element;
  var subElement = et.SubElement;
  var data='&lt;?xml version="1.0"?&gt;&lt;entries&gt;&lt;entry&gt;&lt;TenantId&gt;12345&lt;/TenantId&gt;&lt;ServiceName&gt;MaaS&lt;/ServiceName&gt;&lt;ResourceID&gt;enAAAA&lt;/ResourceID&gt;&lt;UsageID&gt;550e8400-e29b-41d4-a716-446655440000&lt;/UsageID&gt;&lt;EventType&gt;create&lt;/EventType&gt;&lt;category term="monitoring.entity.create"/&gt;&lt;DataCenter&gt;global&lt;/DataCenter&gt;&lt;Region&gt;global&lt;/Region&gt;&lt;StartTime&gt;Sun Apr 29 2012 16:37:32 GMT-0700 (PDT)&lt;/StartTime&gt;&lt;ResourceName&gt;entity&lt;/ResourceName&gt;&lt;/entry&gt;&lt;entry&gt;&lt;TenantId&gt;44445&lt;/TenantId&gt;&lt;ServiceName&gt;MaaS&lt;/ServiceName&gt;&lt;ResourceID&gt;enAAAA&lt;/ResourceID&gt;&lt;UsageID&gt;550e8400-e29b-41d4-a716-fffffffff000&lt;/UsageID&gt;&lt;EventType&gt;update&lt;/EventType&gt;&lt;category term="monitoring.entity.update"/&gt;&lt;DataCenter&gt;global&lt;/DataCenter&gt;&lt;Region&gt;global&lt;/Region&gt;&lt;StartTime&gt;Sun Apr 29 2012 16:40:32 GMT-0700 (PDT)&lt;/StartTime&gt;&lt;ResourceName&gt;entity&lt;/ResourceName&gt;&lt;/entry&gt;&lt;/entries&gt;'
  etree = et.parse(data);
  var t = process.hrtime();
  // [ 1800216, 927643717 ]
  
  setTimeout(function () {
    t = process.hrtime(t);
    // [ 1, 6962306 ]
    console.log(etree.findall('./entry/TenantId').length); // 2
    console.log('benchmark took %d seconds and %d nanoseconds', t[0], t[1]);
    //benchmark took 1 seconds and 6962306 nanoseconds
  },1000);
  </code></pre>
  
  <p>I want to run the above code once per hour and parse the data. For my reference I had used one second as the timer value. Any idea how to proceed will be much helpful. </p>