Run Script on Startup with Raspbian Jessi Wheezy and Raspberry Pi2b [closed]

*爱你&永不变心* 提交于 2019-12-08 07:52:51

问题


I know there are lots of posts on this topic, but depite working through many many many of them I cant get this working.

I have a raspberry pi2b with raspbian jessie wheezy.

I want to run this framebuffer command automatically on startup:

sudo /usr/bin/fbi -T 1 -t 1 -1 -a -noverbose /home/pi/Pictures/*.jpg


I initially edited rc.local and into it I tried each of these commands but nothing happened on startup:

sudo /usr/bin/fbi -T 1 -t 1 -1 -a -noverbose /home/pi/Pictures/*.jpg

and

sudo fbi -T 1 -t 1 -1 -a -noverbose /home/pi/Pictures/*.jpg


so then I created a script called script_auto_run in my /home/pi/projects/test folder containing the following code:

#!/bin/bash
# Script to start our application
sudo /usr/bin/fbi -T 1 -t 1 -1 -a -noverbose /home/pi/Pictures/*.jpg

into rc.local I placed

sudo /home/pi/projects/test/script_auto_run

Again nothing happens on startup


So then I re-created my script_auto_run file in my /etc/init.d folder and its contents are as follows:

#!/bin/bash
# /etc/init.d/script_auto_run
### BEGIN INIT INFO
# Provides:          servoblaster
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This service is used to manage a servo
### END INIT INFO
sudo /usr/bin/fbi -T 1 -t 1 -1 -a -noverbose /home/pi/Pictures/*.jpg
exit 0

I ran the sudo chmod +x /etc/init.d/script_auto_run command and then edited my rc.local yet again to the following line:

sudo /etc/init.d/script_auto_run

None of these are working. I can run rc.local or script_auto_run from the terminal manually and there is no problem. But they are not executing automatically on startup. Raspbian is just booting to the GUI as normal.


回答1:


I suggest to follow this http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/custom-boot-up-screen. It works for me and it's easy. Hope it helps




回答2:


I needed to create a link in rc0.d through rc6.d folders. Raspbian was looking in these folders to see what scripts needed to be run on startup and there was nothing telling it to run my script. I used the following command from the /etc/init.d folder where script_auto_run is located:

sudo update-rc.d script_auto_run defaults

I also required the & symbol in my script file so my script runs while rasbian continues to boot, otherwise the first image flashed up then the boot sequence just continued.

Always nice to figure it out...with a little help from my friend Google!



来源:https://stackoverflow.com/questions/35162180/run-script-on-startup-with-raspbian-jessi-wheezy-and-raspberry-pi2b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!