title: Why won't cron execute my node.js script?
body: <p>I want my server to execute a node script every minute. The program executes perfectly if I execute the file manually (<code>./main.js</code>), so I'm pretty sure it's not the problem. But when I hand it over to cron to execute, nothing happens. </p>
  
  <p>Here's the line from the cron file.</p>
  
  <p><code>*/1 * * * * /home/bryce/scripts/wudu/main.js</code></p>
  
  <p>And here's a sample log:</p>
  
  <p><code>Oct 11 15:21:01 server CROND[2564]: (root) CMD (/home/bryce/scripts/wudu/main.js)</code></p>
  
  <p>The executable: <code>home/bryce/scripts/wudu/main.js</code></p>
  
  <pre><code>#!/usr/bin/env node
  
  var program = require('commander');
  var v = require('./cli/validation');
  var a = require('./cli/actions');
  
  program
    .version('0.0.1')
    .option('-u, --url', 'Register url')
    .option('-s, --selector', 'Register selector')
    .option('-p, --pagination', 'Register pagination')
    .option('-i, --index', 'Pass an index, to destroy')
    .parse(process.argv);
  
  var args = process.argv.slice(2),
          mode = v.mode(args[0]),
          options = v.hasArgs(mode, program);
  
  a.init(mode, options);
  </code></pre>
  
  <p>Any idea why I'm getting radio silence? Somewhere else I should be looking to debug?</p>
  
  <p>UPDATE: </p>
  
  <p>I believe the problem has to do with my relative filepaths, and main.js being executed from outside its own directory. </p>
  
  <p>So now, I've placed <code>exe.sh</code> in the <code>wudu</code> directory. It looks like this: </p>
  
  <pre><code>#!/bin/bash
  
  cd ${0%/*}
  ./main.js mail
  
  exit
  </code></pre>
  
  <p>Now, I've set cron to execute this file every minute. I tried executing this file from other folders, and it works as expected. But again, cron isn't picking it up. </p>