LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 06-29-2017, 08:41 AM   #1
Assomnia
Member
 
Registered: May 2017
Posts: 38

Rep: Reputation: Disabled
Script won't boot at startup


Hello there,

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

Thanks
 
Old 06-29-2017, 08:46 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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?

Last edited by BW-userx; 06-29-2017 at 09:01 AM.
 
Old 06-29-2017, 08:53 AM   #3
Assomnia
Member
 
Registered: May 2017
Posts: 38

Original Poster
Rep: Reputation: Disabled
/etc/rc.d I have no such file or do you mean rc.local ?
 
Old 06-29-2017, 09:03 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by Assomnia View Post
/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.

Last edited by BW-userx; 06-29-2017 at 09:04 AM.
 
Old 06-29-2017, 09:27 AM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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#
showing it works.

Last edited by BW-userx; 06-29-2017 at 09:29 AM.
 
Old 06-29-2017, 10:00 AM   #6
Assomnia
Member
 
Registered: May 2017
Posts: 38

Original Poster
Rep: Reputation: Disabled
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

Last edited by Assomnia; 06-29-2017 at 10:01 AM.
 
1 members found this post helpful.
Old 06-29-2017, 10:07 AM   #7
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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.

the login too has to be completed as well, yes?

Last edited by BW-userx; 06-29-2017 at 10:17 AM.
 
1 members found this post helpful.
Old 06-29-2017, 10:26 AM   #8
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
is the script executable by root ?
maybe you need to put the /full/path/to/echo ?
 
Old 06-30-2017, 04:20 AM   #9
Assomnia
Member
 
Registered: May 2017
Posts: 38

Original Poster
Rep: Reputation: Disabled
I actually used sudo nano /etc/profile
And did my change there as the pi autologin so the script start at boot

~@schneidz No it is start by the user pi
 
Old 06-30-2017, 05:47 AM   #10
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
^ maybe it should go in the users .profile or .bash_profile ?
 
Old 06-30-2017, 08:26 AM   #11
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
@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.

But it's good you figured it out.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trobule figuring out why a script won't run at system startup laredotornado Linux - General 3 12-11-2014 12:22 PM
Startup script won't access configuration. geomysterio Linux - Newbie 10 05-24-2009 12:16 AM
samba script won't load during startup and i never get to a login screen nass Slackware 9 04-06-2009 09:47 AM
Why won’t this init.d startup script work? dholingw Linux - Software 2 06-08-2004 02:40 PM
Console won't scroll boot log on startup dfowensby Red Hat 0 05-20-2004 09:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration