供测试的python脚本testboot.py(确认你的python3路径二选一):
#!/usr/bin/python3
with open('testboot.txt',"w") as f:
print('test')
f.write('testboot\n')
f.close()
或者:
#!/usr/local/bin/python3
with open('testboot.txt',"w") as f:
print('test')
f.write('testboot\n')
f.close()
修改.py权限:
sudo chmod 777 testboot.py
修改rc.local:
vim /etc/rc.local
在exit 0 前加上:
cd /home/user/ && python3 testboot.py
重启linux
reboot
重启后查看文件:
cat testboot.txt
应该会显示
testboot