0

-My problem:

I can't get autostart to work (/etc/rc.local or /etc/init.d)

/etc/rc.local screen never boots and kills the pi, which then needs to be re-flashed to work again.

/etc/init.d no auto start. Pi is still alive.

/etc/rc.local I can not ssh into the machine to delete the rc.local and holding down shift does not boot into safe mode. so I have to re-flash the .img to try again. and then fail again.

I am following goldilocks help example pifm Crash Loop my Raspberry Pi and code from http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter#Steps_to_play_sound:

#!/bin/bash
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/bin
(
  exec &>> /var/log/my_rc_local.log
  cd /home/pi/pifm && ./pifm sound.wav 90.5 
) &

exit 0

I have tried deleting: export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/bin

I have also tried different spacing with no luck

#!/bin/bash
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/bin
(
 exec &>> /var/log/my_rc_local.log
 cd /home/pi/pifm && ./pifm sound.wav 90.5 
)&

exit 0

using a /etc/init.d/file.sh

#!/bin/bash
cd /home/pi/pifm
sudo ./pifm sound.wav 90.5

then made the script executable using

sudo chmod 755 /etc/init.d/file.sh

the test worked!!!

sudo /etc/init.d/file.sh start

then registered the script

sudo update-rc.d file.sh defaults

the pi boots/starts but the file.sh is not auto started.

any ideas?

6
  • only thing I can suggest is delaying the execution of pifm perhaps put a sleep 10 in the line before? Commented Apr 17, 2018 at 4:17
  • Is there anything in the log file: /var/log/my_rc_local.log Commented Apr 17, 2018 at 10:41
  • I can not get to the .log as the pi is killed. no ssh. and no safe mode. no way to see log file. any ideas John
    – Duffman
    Commented Apr 17, 2018 at 17:12
  • I have also tried a /etc/init.d file. it does not kill the pi but no autostart.
    – Duffman
    Commented Apr 17, 2018 at 18:37
  • created the .sh file put it in etc/int.d then made it executable and the test file.sh worked in terminal. then sudo update-rc.d file.sh defaults to register the script. when I reboot, the pi does not autostart the etc/init.d/file.sh file.
    – Duffman
    Commented Apr 17, 2018 at 18:57

1 Answer 1

1

from Jaromanda X below in comments add "sleep 10" to the line before

#!/bin/bash
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/bin
sleep 10
(
  exec &>> /var/log/my_rc_local.log
  cd /home/pi/pifm && ./pifm sound.wav 90.5 
) &

exit 0
1
  • please post an answer Jaromanda X so I can give you credit. thanks again!!!
    – Duffman
    Commented Apr 17, 2018 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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