Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to run a .sh script ONCE when I boot? I know about the init.d folders, but there seems to be some weird special layout you must use for scripts there.

I only want to run two quick lines of code, nothing huge. I'm running the latest Raspbian.

Any tips?

share|improve this question

closed as off-topic by MadHatter, Iain, MichelZ, Jenny D, Tom O'Connor May 13 '14 at 14:02

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

We don't consider RPis to be servers within the meaning of ServerFault. We consider Super User, Raspberry Pi or Unix & Linux to be better suited to the enthusiast nature of this device. – Iain May 13 '14 at 12:00
I don't know if it works in Raspbian, but some crontabs allow you to specify time as @reboot. – Jenny D May 13 '14 at 13:53
up vote 1 down vote accepted

This is NOT standard compliant, but it works:

Create a new file in /etc/init.d -->

case "$1" in

exit 0

then set the executable bit and remove all other permissions: chmod 700 /etc/init.d/filename

and then configure your service to autostart: update-rc.d filename defaults

Hope this helps, Tobias

share|improve this answer
Seems to have done it, thanks :) – user3433131 May 13 '14 at 12:01

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