Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question
    
What is your init? –  mikeserv Apr 14 at 1:35
    
@mikeserv Is that a file? –  evamvid Apr 14 at 1:37
    
    
@mikeserv the OP is (probably) using raspbian which (probably) uses sysvinit. –  terdon Apr 14 at 1:49
2  
@evamvid that's the kind of thing you should include in the question itself. –  terdon Apr 14 at 1:51

3 Answers 3

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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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