I've solved this by adding a line to the cron job that sets the environment 
variable NODE_PATH.

NODE_PATH=/usr/local/lib/node_modules
# m h dom mon dow user  command
@reboot   root    sleep 120 && /usr/bin/nodejs /root/boneboot/ledsoff.js 2>&
1 | logger -p info -t ledsoff


On Friday, 18 December 2015 22:38:53 UTC+1, Maurice H. wrote:
>
>
> I have this simple script that I want to execute at boot time.
>
> The script:
> root@bbone:~# cat boneboot/ledsoff.js
> var b=require('bonescript');
>
>
> b.pinMode('USR0', 'out');
> b.pinMode('USR1', 'out');
> b.pinMode('USR2', 'out');
> b.pinMode('USR3', 'out');
>
>
> b.digitalWrite('USR0', 0);
> b.digitalWrite('USR1', 0);
> b.digitalWrite('USR2', 0);
> b.digitalWrite('USR3', 0);
>
> To run it at boot I've created a file in /etc/cron.d which looks like this:
> root@bbone:~# cat /etc/cron.d/boneboot
> # m h dom mon dow user  command
> @reboot   root    sleep 120 && /usr/bin/nodejs /root/boneboot/ledsoff.js 2
> >&1 | logger -p info -t ledsoff
>
> Unfortunately, when I reboot the BBB the code is not executed succesfully 
> as shown by the log:
> root@bbone:~# cat /var/log/syslog
> Dec 18 21:54:49 bbone ledsoff:
> Dec 18 21:54:49 bbone ledsoff: module.js:340
> Dec 18 21:54:49 bbone ledsoff:     throw err;
> Dec 18 21:54:49 bbone ledsoff:           ^
> Dec 18 21:54:50 bbone ledsoff: Error: Cannot find module 'bonescript'
> Dec 18 21:54:50 bbone ledsoff:     at Function.Module._resolveFilename (
> module.js:338:15)
> Dec 18 21:54:50 bbone ledsoff:     at Function.Module._load (module.js:280
> :25)
> Dec 18 21:54:50 bbone ledsoff:     at Module.require (module.js:364:17)
> Dec 18 21:54:50 bbone ledsoff:     at require (module.js:380:17)
> Dec 18 21:54:50 bbone ledsoff:     at Object.<anonymous> (/root/boneboot/
> ledsoff.js:1:69)
> Dec 18 21:54:50 bbone ledsoff:     at Module._compile (module.js:456:26)
> Dec 18 21:54:50 bbone ledsoff:     at Object.Module._extensions..js (
> module.js:474:10)
> Dec 18 21:54:50 bbone ledsoff:     at Module.load (module.js:356:32)
> Dec 18 21:54:50 bbone ledsoff:     at Function.Module._load (module.js:312
> :12)
> Dec 18 21:54:50 bbone ledsoff:     at Function.Module.runMain (module.js:
> 497:10)
>
> However, when I logged in as root, the code executes normally.
>
> Any suggestions on how to proceed?
>
>
>
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to