简体   繁体   English

Raspberry Pi Zero W启动时启动脚本

[英]Raspberry Pi Zero W start script on startup

I'm creating a time-lapse camera to attach to a pair of glasses. 我正在创建一个延时摄影机,以将其安装到一副眼镜上。

I tried out my script (python 3) and it works, but I need to get my script to work upon startup up since it will powered by a powerbank and I can't manually start the script because of that. 我尝试了我的脚本(python 3),它可以工作,但是我需要让我的脚本在启动时才能工作,因为它将由移动电源供电,因此我无法手动启动该脚本。 (filename is "GlassCam.py" in the folder named "GlassCam") (文件名为“ GlassCam”的文件夹中的文件名为“ GlassCam.py”)

This is what I've tried in the command line: 这是我在命令行中尝试过的:

sudo nano ~/.config/lxsession/LXDE-pi/autostart

then in the menu 然后在菜单中

sudo /usr/bin/python3 /home/pi/GlassCam/GlassCam.py

(control+x and then y to save) (先按Control + x,然后按y保存)

yet it won't start when I reboot it or shut it down and plug it back in 但是当我重新启动或关闭它并重新插入时它不会启动

尝试创建一个cron作业: sudo crontab -e ,然后将您的脚本添加到文件的末尾(在重新启动时执行),如下所示: @reboot python /home/pi/GlassCam/GlassCam.py &

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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