-1

I want to put myScript.sh on autostart.

I have set the configuration.

chmod +x /etc/init.d/myScript.sh

And enable it

sudo update-rc.d /etc/init.d/myScript.sh defaults

But when I run the myScript.sh I get an error because of the flag -bootRun. myScript.sh looks like this:

sudo /home/pi/path/to/my/program/gradlew -bootRun

How can I run this script instead?

Edit:

I listen to that guy below. I place my code at the rc.local at /etc in Raspberry.

enter image description here

But when I run I ge this error. Why?

enter image description here

enter image description here

enter image description here

euraad
  • 2,467
  • 5
  • 30
  • 51
  • Your init script is missing quite a bit. Compare it to other files in the same directory. Maybe you'd rather look up [how to run a command on boot](https://www.raspberrypi.org/documentation/linux/usage/rc-local.md)? – that other guy Oct 21 '19 at 22:55
  • @thatotherguy I just followed this "manual" https://raspberrypi.stackexchange.com/questions/15475/run-bash-script-on-startup – euraad Oct 21 '19 at 23:01
  • The problem with that is that it'll work poorly with commands that don't exit quickly, and it'll re-run the command when you're shutting down and things like that. Check out the [more upvoted](https://raspberrypi.stackexchange.com/a/15478) answer on the same question. – that other guy Oct 21 '19 at 23:03
  • @thatotherguy Ok! I will try that :) – euraad Oct 21 '19 at 23:03
  • @thatotherguy See my updated question now. – euraad Oct 21 '19 at 23:24
  • That means your command doesn't work. Please make sure the command works independently before you try to run it on boot. Google suggests there shouldn't be a dash in it – that other guy Oct 21 '19 at 23:30
  • @thatotherguy But I need the bootRun flag and it needs a dash. – euraad Oct 21 '19 at 23:37
  • @thatotherguy I used to run the `gradlew` command with `./gradlew -bootRun`. That works. – euraad Oct 21 '19 at 23:38
  • Did you actually run `./gradlew bootRun` instead without the dash? – that other guy Oct 21 '19 at 23:57
  • @thatotherguy Yes. But I used cd to direct my self to the `gradlew` file. That solved my problem. Thank you very much for the help. See the answer. As a thank you, I give you this IoT tool. https://github.com/DanielMartensson/JLogger – euraad Oct 22 '19 at 00:45
  • Please replace your screenshots with actual text. There are many reasons to NOT use screenshots, most importantly, readers can't search inside of them. Use the `{}` from the Edit menu on mouse-selected text to get proper formatting for code/data/errMsgs. Good luck. – shellter Oct 22 '19 at 02:34
  • @shellter Sorry, I was not able to use mouse at that time. I was using SSH and could not post code. – euraad Oct 22 '19 at 12:54

1 Answers1

0

Here is the solution. Thanks to theotherguy above!

enter image description here

euraad
  • 2,467
  • 5
  • 30
  • 51