Set the fastest python file execution after starting Raspberry Pi.

Premise

--Preparation of Raspberry Pi --The Raspberry Pi OS is installed on the microSD, and you can start the Raspberry Pi. --The Raspberry Pi code is written using an external keyboard, mouse, and display.

things to do

  1. Give permission to execute the file you want to execute
  2. Write the command to be executed when starting Raspberry Pi in the specified file.

Give permission to execute the file you want to execute

First, in the Raspberry Pi terminal, move to the directory containing the file you want to execute. I saved it on my desktop so I moved there

sudo chmod 755 filename.extension

In the case of I

Desktop


sudo chmod 755 test.py

Execution authority is now okay.

Write a command to execute the file at startup

The file loaded at startup is located in /etc/rc.local. Execute the following command in the terminal.

sudo nano /etc/rc.local

On echo 0, enter the command you want to execute at startup.

//Described here
echo 0

In my case it runs the Python file on my desktop

python3 /home/pi/Desktop/test.py 

Save with this. You can save it with ctr + o, ​​then with enter, and with ctr + x.

This will execute the specified file when you start Raspberry Pi instead of GUI operation.

bonus

What is chmod that came out on the way this time?

The chmod that appears on the way is the authority. What to do with the permissions of that file ,. about it. This time I wrote the authority 755.

According to Reference Site Regular directories, commands, CGI scripts, etc. Anyone can read and execute, but only write. It is the authority.

Reference site

Recommended Posts

Set the fastest python file execution after starting Raspberry Pi.
Sound the buzzer using python on Raspberry Pi 3!
How to use the Raspberry Pi relay module Python
Download the file in Python
It was great to edit the Python file in the Raspberry Pi with Atom's remote function
Raspberry Pi + Python + OpenGL memo
After enabling the python virtual environment in the batch file, run the python file
raspberry pi 1 model b, python
After calling the Shell file on Python, convert CSV to Parquet.
Extract the xz file with python
Use vl53l0x with Raspberry Pi (python)
Save the binary file in Python
Extract the targz file using python
[Raspberry Pi] Changed Python default to Python3
Use python on Raspberry Pi 3 to light the LED with switch control!
I connected the thermo sensor to the Raspberry Pi and measured the temperature (Python)
[Python] Set the graph range with matplotlib
Detect "brightness" using python on Raspberry Pi 3!
Raspberry Pi Security Infrared Camera (Python Edition)
Check the existence of the file with python
Associate the table set in python models.py
Let's read the RINEX file with Python ①
Set swap space on Ubuntu on Raspberry Pi
Use the Grove sensor on the Raspberry Pi
Read the file line by line in Python
Read the file line by line in Python
Run servomotor on Raspberry Pi 3 using python
In search of the fastest FizzBuzz in Python
Set the process name of the Python program
[Python] Get the character code of the file
Detect temperature using python on Raspberry Pi 3!
[Python] Read the specified line in the file
[Python3] Understand the basics of file operations
Working with GPS on Raspberry Pi 3 Python
Periodically notify the processing status of Raspberry Pi with python → Google Spreadsheet → LINE
Creating a temperature control system with Raspberry Pi and ESP32 (3) Recipient Python file
Using the 1-Wire Digital Temperature Sensor DS18B20 from Python on a Raspberry Pi
Try to use up the Raspberry Pi 2's 4-core CPU with Parallel Python
Use python on Raspberry Pi 3 and turn on the LED when it gets dark!