Linux init task

Modify rc.local

/etc/rc.local add command before exit 0
script must have execute authority x

update-rc.d command

1
2
3
4
5
6
sudo cp -f /home/pi/autowifi.sh /etc/init.d/
[ln -s /home/pi/autowifi.sh /etc/init.d/autowifi]
sudo chmod +x /etc/init.d/autowifi.sh
sudo chown root:root /etc/init.d/autowifi.sh
sudo update-rc.d autowifi.sh defaults 99
sudo update-rc.d -f autowifi.sh remove
  1. add file or link to /etc/init.d
  2. add execute authority to script
  3. add user authority to script
  4. command add script to init start
  5. defaults [num] mean start sequence, the bigger the latter.
1
2
update-rc.d [-n] [-f] name remove
update-rc.d [-n] name default [NN | SS KK]
  • -n do nothing, only preview.
  • -f delete link, even script remain in /etc/init.d
  • NN execute sequence
  • SS begin sequence KK end sequence