barrybinnenweg
Posts: 1
Joined: Wed May 07, 2014 8:29 am

init.d

Wed May 07, 2014 8:59 am

I’m trying to startup a script at boot by placing it in /etc/init.d
while true; do
python3 p1.py -c 1 -l 10 -pvo Y -pvoapi -pvosys
echo "P1 monitoring script disrupted ... Restarting script."
done

and next: sudo update-rc.d p1script defaults

but this produces a looping script at startup and makes the RPI unresponsive.
What should I change to make this work?

Barry Binnenweg

Aydan
Posts: 729
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: init.d

Wed May 07, 2014 9:53 am

Hi Barry

You should not put your looping script into init.d.
Your script in init.d should start your actual script like so:
/your/script/location/script.sh &

this means "start the script but don't wait for it to finish"

Regards
Aydan

gkreidl
Posts: 6335
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: init.d

Wed May 07, 2014 9:58 am

Have a look at other scripts in /etc/init.d to learn how to create such a script. You'll also find help on the internet.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

User avatar
DougieLawson
Posts: 39303
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: init.d

Wed May 07, 2014 10:05 am

Sorry Aydan, but you're wrong.

The /etc/init.d scripts normally use start-stop-daemon to get the application daemon started. If you have a badly behaved daemon program that doesn't fork itself into the background you can use start-stop-daemon --background ... to overcome that problem.

There's a skeleton script /etc/init.d/skeleton that gives you the basics of getting a daemon running.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Aydan
Posts: 729
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: init.d

Wed May 07, 2014 10:19 am

DougieLawson wrote:Sorry Aydan, but you're wrong.

The /etc/init.d scripts normally use start-stop-daemon to get the application daemon started. If you have a badly behaved daemon program that doesn't fork itself into the background you can use start-stop-daemon --background ... to overcome that problem.

There's a skeleton script /etc/init.d/skeleton that gives you the basics of getting a daemon running.
My solution might be wrong, but the reason for it being stuck is still valid.
Whenever you call something from init.d that runs infinitely, the init sequence is stuck.

Return to “Troubleshooting”