简体   繁体   中英

How can I make chromium run on startup using Raspberry Pi 3?

I have a Raspberry Pi 3 - Model B, with Raspbian jessie operation system. Im trying to open "chromium" on startup.

i wrote a simple script:

#!/bin/bash
/usr/bin/chromium-browser --noerordialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://www.google.com
exit 0

I can run the script manually and it works perfect. I read about a lot of various ways to run this script on startup. I have tried: adding this line @reboot path/to/my/script to crontab -e file with no success.
Also i have tried to edit /etc/rc.local file by adding this line:

#!/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.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
  /home/pi/Desktop/script1.sh&   <-------- THIS LINE 
fi
exit 0

I have checked that the script is executable and rc.local too:

  • rwxrwxrwx 1 pi pi script1.sh
  • rwxr-xr-x 1 root root rc.local

I can see script1.sh tesk on my Task Manger (it runs as root) but nothing happen.

The default user is Pi and i log as a Pi user and not as root, maybe this is the problem? Can someone explain me what is the problom and why i can see the script only in the Task Manager? what should i do ? TNX!

UPDATE i have changed the rc.local to be like:

!/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.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
  su - pi -c "/usr/bin/chromium-browser --noerordialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://www.google.com &"
fi
exit 0

still does not work for me :|

Check out the verified answer on this question... Running Shell Script after boot on Raspberry PI

Looks like you need to run the script as the user pi .

su - pi -c "/usr/bin/chromium-browser --noerordialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://www.google.com &"

EDIT: I missed the & at the end of the command.

I did a small hack...

I added this line @lxterminal to the end of this file:

nano .config/lxsession/LXDE-pi/autostart

It will auto-start terminal on boot.

Then I edited $ sudo nano .bashrc file. At the end of the file, I added my path to my script.

./home/pi/Desktop/script.sh

It means that:

  1. The terminal will open every time you boot your Raspberry Pi (first command).

  2. Every time that terminal runs, my script will run also (second command)

It does work for me. TNX for the help :)

Adding the shell script path directly to ~/.config/lxsession/LXDE-pi/autostart (not to ~/.bashrc) works better.

Namely it does not execute the command every terminal session (including ssh).

Try this in the autostart file instead:

@sh /home/pi/Desktop/script.sh &

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM