The first type: the application starts automatically

1. In the config/autosatrt/XX. Add the following to the desktop text, folders and files need to create your own. XX can be replaced by any name.

2. The code contains at least three lines of content, Exec indicates the program or script file to be started.

 [Desktop Entry]
Type=Application
Exec=python3 /home/pi/main.py
Copy the code

The second option is rc.local

1. Run the following command to compile the file

sudo nano /etc/rc.local
Copy the code

2. Enter the script to be executed. Ensure that exit0 is at the end of the line.

python3 /home/pi/text.py&
Copy the code

Third type: Scheduled start (crontab -e)

1. On the CLI, run crontab -e

corntab -e
Copy the code

2. Enter the code to be executed. The following code is executed at 00:00 every day

0 0 * * *  /home/pi/1.sh
Copy the code

3. Run the 1.sh command every three minutes

*/3   *  *  *  *       /usr/pi/1.sh
Copy the code

4. The specific time Settings are as follows:

# m h dom mon dow command # # * * * * * command to execute ┬ ┬ ┬ ┬ ┬ # │ │ │ │ │ # │ │ │ │ │ # │ │ │ │ └ ─ ─ ─ ─ ─ What day of a week (# 1-7) │ │ │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ in (# 1-12) │ │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ day of the month (1-31) # │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ hours (0 8) # imp ── minute (0-59)Copy the code

Note: If it does not run, see if the program is set to executable (with executable permissions)

Sudo chmod +x code/program to executeCopy the code