Trying to add off button with script at startup, not working

If you are always running your script from /etc/rc.local, you don’t need sudo, as it’s always run as a root user.

Check that /etc/samplerun.sh has the execute bit (chmod +x) set.

Also note: it appears the original author starts it in a backgrounded subshell. This suggests to me that whatever you’re running is a long-term process. You should do the same, or it will hang. Further more – if the service dies, it will not be restarted as it is not being managed by init.

We have an early Wiki on running things at startup: Running scripts on startup and shutdown

Sam