在 Raspberry Pi 启动时启动 shell 脚本 [英] Start shell script on Raspberry Pi startup

查看:71
本文介绍了在 Raspberry Pi 启动时启动 shell 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 python 程序可以发布到我的本地 Web 服务器.该脚本在运行最新版本 raspbian 3.18 的 raspberry pi 上运行.如何让 Python 脚本在启动时运行?Raspbian 有一个登录密码,这是我必须删除的第一件事.如果停电,我希望 pi 重新启动并再次开始运行我的脚本.我应该为此使用 Raspbian 吗?脚本是 pi 的唯一用途.我尝试将脚本添加到/etc/init.d,但如果 pi 在启动时需要登录信息,我认为它不会以任何方式运行.

I have a python program which posts to my local web server. The script runs on a raspberry pi running the latest version of raspbian 3.18. How can I make the Python script run at startup? Raspbian has a login password which is the first thing I have to remove. If the power ever goes out I want the pi to reboot and start running my script again. Should I be using Raspbian for this? The script is the only thing the pi is used for. I tried adding the script to /etc/init.d but I do not think it will run either way if the pi requires login info upon booting.

推荐答案

确保程序可执行

chmod +x filename.py

在您选择的编辑器中打开/etc/rc.local

open /etc/rc.local in your editor of choice

sudo nano /etc/rc.local

并添加

python /FULL PATH TO SCRITP/filename.py

出口前

这篇关于在 Raspberry Pi 启动时启动 shell 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆