供測試的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