5

I've bee reading about running scripts at startup since last weak with no results. I just need to run an application located on my home (/home/pi) at startup (unattended). I tried creating a script at /etc/init.d/, /etc/rc.local, etc. Nothing seems to work.

It only works when run on the console (logged in), but I'd like to make it run every time the system boots and it even respawns when it crashes.

FYI:

$ uname -a 
Linux soldaraspi 3.10.25+ #622 PREEMPT Fri Jan 3 18:41:00 GMT 2014 armv6l GNU/Linux

TIA!

vazquezjm
  • 61
  • 1
  • 1
  • 3

2 Answers2

6

Try starting it this way at the beginning of /etc/rc.local:

/full/path/to/myscript.js < /dev/null &

& forks it into the background, presuming this is a persistent process. < /dev/null (redirecting standard input to ensure the handle stays open) is probably not necessary, but may make a difference.

You need to use the absolute path in rc.local since $PATH may be empty when the script is run. So even if the file is in /bin, you'd need /bin/whatever.

goldilocks
  • 58,859
  • 17
  • 112
  • 227
1

I think that placing the script in /etc/init.d was the right idea!

Supposed that it was already set executable, the only thing missing was to actually register it with

sudo update-rc.d YourScript defaults