Skip to content

Instantly share code, notes, and snippets.

@RickyRomero
Created November 5, 2014 19:08
Show Gist options
  • Save RickyRomero/def1ea977f6d9b7d43ef to your computer and use it in GitHub Desktop.
Save RickyRomero/def1ea977f6d9b7d43ef to your computer and use it in GitHub Desktop.
Simple StartCalendarInterval launchd test with node.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.test</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/node</string>
<string>/test.js</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Minute</key>
<integer>4</integer>
</dict>
<dict>
<key>Minute</key>
<integer>5</integer>
</dict>
<dict>
<key>Minute</key>
<integer>6</integer>
</dict>
<dict>
<key>Minute</key>
<integer>7</integer>
</dict>
<dict>
<key>Minute</key>
<integer>8</integer>
</dict>
</array>
</dict>
</plist>
fs = require('fs');
// for verifying respawns
fs.writeFileSync('/' + Number(new Date()) + '.txt', 'hi');
// comment out below to stop process immediately after writing
setInterval(function () {
console.log('hi! ' + Number(new Date()));
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment