Rc. local file of Raspberry Pi (set startup), raspberry rc. local
To run a command or program when Raspberry Pi is started, you need to add the commandRc. localFile. This is useful when you want to run the program directly without configuring it after Raspberry Pi is powered on, or do not want to start the program manually every time.
Another method to replace a scheduled task is to use cron and crontab.
Editing rc. LOCAL (edit the rc. local file)
On your Raspberry Pi, select a text editor to edit/Etc/rc. localFile. You must use the root permission for editing. For example:
sudo vim /etc/rc.local
Add the command after the annotation, but make sure thatExit 0This line of code is at the end, and then save the file and exit.
WARNING (note)
If your command needs to run for a long time (such as an endless loop) or cannot exit after running, make sure that you add&Symbol to run the command in other processes, for example:
python /home/pi/myscript.py &
Otherwise, the script cannot end and Raspberry Pi cannot start. This&Symbol allows the command to run in a specified process, and then continue to run the START process.
In addition, make sure that the file name uses an absolute path instead of a relative path relative to your home directory. For example/Home/pi/myscript. pyInstead of usingMyscript. py.
Address: http://www.raspberrypi.org/documentation/linux/usage/rc-local.md
How can Raspberry Pi execute a command when it is started?
The simplest method is to directly add it to the exit statement of the/etc/rc. local file. Write the startup script and put it in init. d. then create a soft link to rc.2. You can also use a third-party startup management software, but it is not recommended.
Why can't I manually start the script I added to/etc/rclocal?
Open gpedit. msc
Computing configuration -- windows Settings -- script (startup/shutdown )--
Double-click Start --- add rc. local File Save and exit.
You can also save the rc. local file in
C: \ WINDOWS \ System32 \ GroupPolicy \ Machine \ Scripts \ Startup here,
Add the rc. local file, save it, and exit.