RC. Local file of Raspberry Pi (set startup)

Source: Internet
Author: User

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


RC. Local file of Raspberry Pi (set startup)

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.