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

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

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.

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.

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.