ก่อนอื่นต้องเตรียมไฟล์ script (ในตัวอย่างนี้คือไฟล์ /home/pi/myscript.py) ที่ต้องการให้เริ่มทำงานอัตโนมัติไว้ก่อน หลังจากนั้นให้ทำตามขั้นตอนต่อไปนี้
[Unit]
Description=This is automatic start script
[Service]
Type=idle
ExecStart=/usr/bin/python /home/pi/myscript.py
[Install]
WantedBy=multi-user.target
$sudo systemctl daemon-reload
$sudo systemctl enable autorunscript.service
ไม่มีความเห็น