Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a issue with a script I wrote. The script work fine when launching manually from the shell but won't start when I reboot or just start my machine. I'm running raspbian with kodi and emulationstation installed manually.
What I tried :
crontab -e and adding : @reboot bash /home/pi/loading.sh & rc.local and adding : bash /home/pi/loading.sh & above 0 exit
Can anyone help me with this ? I read something about init.d but I'm confused really
is rc.local marked executable?
when booting is that script in a partition it can be gotten to as in it needs to be mounted first so it can access it, is an absolute path to script and script name within the rc.local.
I do not think you need to add the word 'bash' in front of that in your rc.local. your shebang for bash is suppose to be inside of your script you want to run !#/bin/bash
so this is not formed properly
Code:
rc.local and adding : bash /home/pi/loading.sh & above 0 exit
Quote:
userx%slackwhere ⚡ imaging ⚡> cat /etc/rc.d/rc.local
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
just:
Code:
/home/pi/loading.sh &
should work, then do a rc.shutdown script if needed like rc.local suggest.
can you on a PI just put that script inside of /etc/rc.d and mod it to reflect a startup script in itself?
/etc/rc.d I have no such file or do you mean rc.local ?
the /etc/rc.d a the directory where all of the startup scripts go. That is where rc.local is located too on a reg Linux/GNU anyways. you might have to update your page as I added more information to that post.
I see that yours looks like it is in /etc/init.d/rc.local
here in my example is a bash script in my home dir
Code:
#!/bin/bash
echo " this is a test of rc.local"
in my /etc/rc.d/rc.local I just added this line in the file
Code:
bash-4.3# cat /etc/rc.d/rc.local
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
#added absolute path and script name -
#marked executable "anyone"
/home/userx/scripts/testing/testRClocal
then ran it and got this -
Code:
bash-4.3# /etc/rc.d/rc.local start
this is a test of rc.local
bash-4.3#
I did the same, I used /etc/init.d/rc.local start and my script appear (even if the script shut off and show "Back to Shell !". It shouldn't but yeah it's there).
There is my script :
Code:
#!/bin/bash
clear
echo -e "Welcome\x1b[31m Asso'\x1b[0m : $(date)"
echo -e "---------------------------------"
echo -e "- Press TRIANGLE ▲ - Kodi"
echo -e "- Press SQUARE ■ - EmulationStation"
echo -e "- Press CIRCLE \033[1mO\033[0m - StartX"
echo -e
echo -e "- Press Any Key - Back to shell"
echo -e "---------------------------------"
echo -e
read -s -N 1 answer
if [ "$answer" == $'\e' ]; then
echo "Kodi is Starting !"
kodi
elif [ "$answer" = $'a' ]; then
echo "EmulationStation is Starting"
emulationstation
elif [ "$answer" == $'\x7f' ]; then
echo "StartX is Starting"
startx
else
clear
echo "Back to Shell !"
exit
fi
so when you boot your PI this is not running/showing up after PI has completely finished booting?
if yes, then
that is/maybe your condition you need to have that check for before starting that script/
if system is completely started then run script, else wait.
@schneidz might be on to something, especially if you're getting that 'do not use as root' message, because that /etc/profile is on the root side of your system. Though placing it there makes it a system wide event. in case yo didn't know.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.