Rc. local file of Raspberry Pi (set startup), raspberry rc. local

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.