First of all, please, read until the end of the story and believe me that this is not a duplicate question - I've read all the possibilities and all the variations of this kind of issue but I didn't found a fix until now.
Second of all - let me tell you about my issue: I have a Raspberry PI 3 updated and upgraded, I have a node.js app (v 4.3.2) which if it's run from the command line when the user is logged in, it runs perfectly but if I'm scheduling the app to be run on startup it doesn't do anything. I mean, the app is running:
492 ? S 0:00 sudo nohup node /home/pi/meteo/meteo.js
527 ? Sl 0:01 node /home/pi/meteo/meteo.js
but it doesn't do anything.
In order to make it to run at startup I used the crontab way of scheduling like this:
@reboot sudo nohup node /home/pi/meteo/meteo.js &> /home/pi/meteo/meteo-reboot.log &
and accordingly to the processes that are running after startup, the application is working but, as I've said, it doesn't do anything.
Few words about the app: it's a simple app which connects to a Bluetooth sensor (TI CC2650) and sends the data to the IoT Hub on Azure. The app doesn't expect any input from the user.
Is there any place where can I see any node.js logging or is there any way of tracing what it might be the issue because I suspect that something might not be initialized when the app starts after reboot.
As you see in my crontab command, I'm sending all the output to a file - if I run that command manually, the meteo-reboot.log file is filled with my app output but if the app is running after startup using the crontab scheduling system, that file is empty and it doesn't get any data in it.
Thank you for your time and hopefully that there is someone who knows how can I get some info about what is wrong.
Evdin
sudo
in the crontab? If you want it run root, run it from the system crontab. Also, if it is run by some user other than pi (e.g., if the system cron is running as user cron, you'll have to check), then note that redirection (&>
) cannot be used with sudo to circumnavigate permissions. E.g., user pi cannotsudo ls $HOME > /list.txt
. – goldilocks Mar 13 '16 at 19:10461 ? Sl 0:01 node /home/pi/meteo/meteo.js
; the crontab command is@reboot nohup node /home/pi/meteo/meteo.js &> /home/pi/meteo/meteo-reboot.log &
– Edi Mar 13 '16 at 19:27rc.local
instead? I think cron probably starts stuff earlier in the boot process, whereas you ideally would have this happen as late as possible (rc.local is run last). You may also find this useful: http://raspberrypi.stackexchange.com/questions/40493/log-output-of-background-or-boot-script -> Although you obviously already have normal logging set up, sometimes applications will throw initialization errors and such to stderr/stdout and you need to catch those differently. – goldilocks Mar 13 '16 at 19:54(sudo nohup /usr/bin/node /home/pi/meteo/meteo.js) &>> /home/pi/meteo/meteo-reboot.log &
and nothing is happening... I suspect that is something wrong with the node.js but I don't know how to investigate this kind of issues. – Edi Mar 13 '16 at 20:51sudo
inrc.local
(or other init scripts which do not de-escalate) is at best totally pointless and at worst a cause of problems. Usingnohup
in this context is also unnecessary. – goldilocks Mar 13 '16 at 20:53(/usr/bin/node /home/pi/meteo/meteo.js) &>> /home/pi/meteo/meteo-reboot.log &
- better now? :-) – Edi Mar 13 '16 at 20:57sudo kill -s 1 [pid]
where[pid]
is node's. There's a list you can see withkill -L
. Try stuff likeABRT
,STOP
,INT
, (or the corresponding numbers), checking the log and whether it is still around each time, move on toTERM
. – goldilocks Mar 13 '16 at 21:05