cron - Why does this node.js script not run in crontab? -


if run node.js script in containing directory, runs fine. if run crontab

*/1 * * * * /usr/local/bin/node /users/full/path/to/main >> ~/mtf.log 

i see errors relating twilio config

var twclient        = require('twilio')(configtwilio.accountsid, configtwilio.                                                 ^ typeerror: cannot read property 'accountsid' of undefined 

why doesn't work when run cron? same behaviour occurs on server (ubuntu) , localhost (osx 10.8.5)

top of script (main.js)

var phantom         = require('phantom'); var portscanner     = require('portscanner'); var feedparser      = require('feedparser'),     request         = require('request'); var configdb        = require('config').db; var configtwilio    = require('config').twilio; var mysql           = require('mysql');  var twclient        = require('twilio')(configtwilio.accountsid, configtwilio.authtoken); 

the config file default.yaml in config directory relative main.js , contains (redacted):

db:   dbhost: localhost   dbport: 3306   dbname: xxx   dbuser: xxx   dbpass: xxx  twilio:   accountsid: ac8fxxxxxxxxd5f7aace47a8   authtoken:  d863b4ddfxxxxxx9b7c845 

i've tried locally:

env -i sh -c 'cd /path/to/script && /usr/local/bin/node main' 

but get:

events.js:72         throw er; // unhandled 'error' event               ^ error: spawn enoent 

if try wrapping inside shell script, may have success setting environment variables in crontab entry.

see answer similar question:

https://stackoverflow.com/a/27823675/608269


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -