1

I've been trying to run this code on startup for the last two days:

Screenshot of code

I've tried the rc.local method, the init.d method and sudo crontab -e method but none of them worked for me !

The file is executable (sudo chmod +x InitiateSensors.js)

I am accessing the Raspberry Pi remotely using xrdp and user pi.

Any ideas why this isn't working ?

  • 1
    Does it work when you start your script manually from a terminal window? And your script seems to rely on the Desktop being active. Have you tried to add it to the LXDE autostart file (/home/pi/.config/lxsession/LXDE-pi/autostart)? – Dirk Sep 2 '18 at 9:10
  • thanks for your answer :D yes manually it's working fine, and no i don't know how to use the LXDE – Tony Sep 2 '18 at 9:11
  • should use /home/pi/.config/lxsession/LXDE-pi/autostart since it needs access to the desktop.. working good, thanks you! – Tony Sep 2 '18 at 9:36
  • 2
    Please post your code as text and not a screenshot, as that makes it searchable and way easier to read. – Greenonline Sep 2 '18 at 10:23
  • @Greenonline the only problem is that I am accessing the pi remotely and didn't find any way to copy paste through xrdp! – Tony Sep 2 '18 at 10:25
4

The script seems to rely on the Desktop being active. The best method is probably to add it to the GUI autostart file. For Raspbian that's /home/pi/.config/lxsession/LXDE-pi/autostart

Add a line Like

@InitiateSensors.js

or

@lxterminal -e InitiateSensors.js

You may have to use the full path to the script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.