在个人文件夹下写了一个python文件,但每次需要登录重启
因此需要写一个自启脚本
在/etc/init.d/下建立一个文件,名字任意
编写文件self_start:
#! /bin/sh
#......可有可无
cd 个人目录
echo '密码xxxx' | sudo -S python /绝对路径/led.py
结束。
添加自启:
sudo chkconfig --add self_start
之后会出现 on
注:树莓派需要自行安装chkconfig sudo apt-get install chkconfig
若显示为不是执行文件,请使用sudo chmod +x self_start