如何使用Raspberry Pi 3在启动时运行铬?
我有一个树莓派3 - 模型B,与Raspbian jessie操作系统。 我试图在启动时打开“铬”。如何使用Raspberry Pi 3在启动时运行铬?
我写了一个简单的脚本:
#!/bin/bash
/usr/bin/chromium-browser --noerordialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://www.google.com
exit 0
我可以手动运行该脚本和它的作品完美。 我读了很多种启动时运行这个脚本的方法。 我试过了: 将此行@reboot path/to/my/script
加到crontab -e
文件中没有成功。
此外,我曾尝试加入这一行编辑/etc/rc.local
文件:
#!/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
我已经检查脚本是可执行和rc.local中太:
- rwxrwxrwx 1个屁屁SCRIPT1。 SH
- rwxr-XR-X 1根根rc.local中
我可以看到SCRIPT1。在我的任务管理器(它以root身份运行)上运行tesk,但没有发生任何事情。
默认用户是Pi,我以Pi用户身份登录,而不是root用户,也许这是问题所在? 有人可以解释我是什么问题,为什么我只能在任务管理器中看到脚本?我该怎么办 ? TNX!
UPDATE 我已经改变了rc.local中是这样的:
!/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
仍然不为我工作:|
我做了一招...... 它是这样的:
第一我有这个线@lxterminal
到该文件的末尾:
nano .config/lxsession/LXDE-pi/autostart
它将在开机自动启动终端。
然后我编辑$ sudo nano .bashrc
在文件的末尾我添加了我的路径到我的脚本。
./home/pi/Desktop/script.sh
这意味着终端将执行每次开机您的树莓派(第一个命令),每次终端将运行你的脚本也将运行(第二个命令) 它做的工作对我来说时间。 TNX的帮助:)
很高兴你明白了! –
检查出这个问题的答案验证... Running Shell Script after boot on Raspberry PI
看起来你需要运行该脚本的用户pi
。
su - pi -c "/usr/bin/chromium-browser --noerordialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://www.google.com &"
编辑:我错过了&
在命令的末尾。
如果我添加这些行我看不到任务管理器上的脚本..:| –
是的你是正确的,ID我手动运行我看到用户是-Pi,并在命令行中的用户是根。 –
抱歉,我错过了&最后。可能的铬因为没有在后台运行而被迫立即关闭。尝试新的脚本。 –
在你的rc.local,你似乎缺少命令名和'&'之间的空格。除此之外,它看起来像你有正确的想法。你可以试试'printf'运行...“; /home/pi/Desktop/script1.sh || printf“FAILED%d”“$?” &'获得更多信息(仔细检查你是否修改了正确的rc.local等) – John
我可以在任务管理器上看到脚本,它也有一个pid,但我无法看到它(浏览器窗口):|也许它适用于背景或其他...任何想法? :| –