3

How can I run a shell script when my Raspberry Pi starts up headless?

I don't want it to be dependent on booting into a console, or logging in, etc. It will literally be plugged into Ethernet and power, nothing else.

I saw this post on RPi SE. The answer was really thorough, but depended on things like logging in, booting to desktop, or booting to console.

How can I run a script on powerup, even if none of these things happen?

Thanks!

evamvid

evamvid
  • 688

3 Answers3

7

You can either add the script to your rc.local file located in /etc/, or create an init script.

One of the easiest ways to create an init script is to use 'pleaserun' . You'll want to use sysv as your platform target. https://github.com/jordansissel/pleaserun

spuder
  • 18,053
1

The option he provides for running a script when you boot to the console will work on a headless installation without requiring a user to log in. It should work with the setup you described.

The other option in a regular Debian install is to edit the /etc/rc.local file, which is run on boot. Creating an init.d script is a cleaner solution, though.

jkt123
  • 531
1

If you want a script to run upon bootup then just stick the call to this script in the file, /etc/rc.local. This script is run upon your system booting up.

slm
  • 369,824