0

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?

2
  • 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.
    – user9517
    May 13, 2014 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, 2014 at 13:53

1 Answer 1

1

This is NOT standard compliant, but it works:

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

#!/bin/bash
case "$1" in
start)
    yourcodehere 
    ;;
esac

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

0

Not the answer you're looking for? Browse other questions tagged .