biker67
Posts: 27
Joined: Wed Oct 24, 2018 1:58 pm

autorun at reboot not working RPI 3b+

Thu Dec 06, 2018 10:54 pm

The URL is explicitly clear on what to do but it does not work. I even changed my password on the RPi to prevent the hangup on reboot.

https://www.bc-robotics.com/tutorials/r ... pberry-pi/

This is my rc.local file that will not run.
I did verify that python3 invokes python on the terminal.
One comment inferred that the path to python might be added to insure runability.

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
python3 /home/pi/mypigraphics/workingget_color.py &
exit 0

Any help appreciated.
Last edited by biker67 on Fri Dec 07, 2018 5:06 pm, edited 1 time in total.

n67
Posts: 896
Joined: Mon Oct 30, 2017 4:55 pm

Re: autorun at reboot not working RPI 3b+

Fri Dec 07, 2018 12:21 am

You have to be clear on why you think it isn't working.

Now, I'm not saying that I necessarily think that it is and you just don't know that it is, although that is one possibility.

I'm saying that it would help us help you if you told us what signs you have that it "isn't working".

Have you done the usual thing of adding this line to your rc.local:

Code: Select all

exec > /tmp/rc-local.out 2>&1;set -x
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

biker67
Posts: 27
Joined: Wed Oct 24, 2018 1:58 pm

Re: autorun at reboot not working RPI 3b+

Fri Dec 07, 2018 2:33 am

To further describe "not working" I can add "at all". The RPi boots the same as it did before attempting to modify rc.local.
Adding the suggested line seems to flash a error about "no such file exist". I have not found a way to halt the boot to read the error.

There is supposed to be 5 ways to do this. Is it time to look at #2?

klricks
Posts: 5919
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: autorun at reboot not working RPI 3b+

Fri Dec 07, 2018 3:09 am

biker67 wrote:
Fri Dec 07, 2018 2:33 am
To further describe "not working" I can add "at all". The RPi boots the same as it did before attempting to modify rc.local.
Adding the suggested line seems to flash a error about "no such file exist". I have not found a way to halt the boot to read the error.

There is supposed to be 5 ways to do this. Is it time to look at #2?
If you are booting to desktop then IMO the easiest way to autostart is to use autostart.

First make sure you have set the execute bits for your file.
AND
Make sure there is a proper 'shebang' as first line in your script:

Code: Select all

 #!/usr/bin/python3
If you have the latest updated Raspbian Stretch then the location of autostart is:

Code: Select all

/etc/xdg/lxsession/LXDE-pi/autostart
Your entry in autostart should be something like this:

Code: Select all

@/home/pi/mypigraphics/workinggetcolor.py
If you need terminal then:

Code: Select all

@lxterminal -e /home/pi/mypigraphics/workinggetcolor.py
In some cases you may need to add a sleep command to delay your program start until after the system has fully logged in.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

biker67
Posts: 27
Joined: Wed Oct 24, 2018 1:58 pm

Re: autorun at reboot not working RPI 3b+

Fri Dec 07, 2018 4:54 pm

[codeexec > /tmp/rc-local.out 2>&1;set -x][/code]
Adding this line to the the rc-local file did not invoke an autorun; only booted to desktop. I guessed that maybe the "-" was a typo; and redid the file with rc.local.out. that did create an rc.local.out ; but I did not notice an rc-local.out file in the same directory.

While waiting for a response on the rc.local and autostart topics , I tried the 2nd of 5 ways listed to autorun python programs involving the
'.bashrc' file. it failed to create an autorun.

Code: Select all

 elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi
echo Running at boot
sudo python /home/pi/mypigraphics/workingget_color.py

biker67
Posts: 27
Joined: Wed Oct 24, 2018 1:58 pm

Re: autorun at reboot not working RPI 3b+

Fri Dec 07, 2018 5:31 pm

[code elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
echo Running at boot
sudo python3 /home/pi/mypigraphics/workingget_color.py
][/code]

I put a "3" on python and saved the ".bashrc" file and rebooted. Went to desktop as usual. BUT when I clicked on the terminal my program ran. Not exactly suitable for "headless" run.
#############
Below is my rc.local file which does not work as well.

[code#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
python3 /home/pi/mypigraphics/workingget_color.py &
exec > /tmp/rc.local.out 2>&1;set -x
exit 0][/code]

biker67
Posts: 27
Joined: Wed Oct 24, 2018 1:58 pm

Re: autorun at reboot not working RPI 3b+

Sat Dec 08, 2018 2:03 am

This code is my /etc/xdg/lxsession/LXDE/autostart file that fails to start the program at boot.

Code: Select all

@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash
@sudo /usr/bin/python3 /home/pi/mypigraphics/workingget_color.py

klricks
Posts: 5919
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: autorun at reboot not working RPI 3b+

Sat Dec 08, 2018 4:48 am

biker67 wrote:
Sat Dec 08, 2018 2:03 am
This code is my /etc/xdg/lxsession/LXDE/autostart file that fails to start the program at boot.

Code: Select all

@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash
@sudo /usr/bin/python3 /home/pi/mypigraphics/workingget_color.py
Are you running the latest and fully updated Raspbian Stretch OS?
Normally you would not use sudo to start a file in /home/pi/......
For testing it is faster to log out of desktop and back in rather than rebooting.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

biker67
Posts: 27
Joined: Wed Oct 24, 2018 1:58 pm

Re: autorun at reboot not working RPI 3b+

Sun Dec 09, 2018 8:14 pm

https://www.raspberrypi-spy.co.uk/2015/ ... y-pi-boot/

The URL above has logical info to create an auto start.
A. sudo raspi-config..... allows for setting the boot plan for your system just like F1..F8...F12 has over the years on windows computers .
B. sudo nano /etc/profile... is where the file to be started at boot is placed.
IF your program fails to execute , while stopped in the terminal mode, edit the profile and reset raspi_config file to boot to desktop and fix your short comings.

I am getting errors from RPi about program lines in the thousands and erros about turtle.setup(799,479).
Is there someway to run the program and get those errors with more info attached??
My program runs fine at "run module".

I will look at getting the most recent Raspian Stretch.

Return to “Beginners”