Linux starts automatically at boot----python3

1. Edit the /etc/rc.d/rc.local file and write the command or file script you want to start automatically at boot, etc.

# 进入文件进行编辑
vim /etc/rc.d/rc.local

2. Place the script you want to run at the bottom of the file. What I want to execute here is python3 server1.0.py , so you need to find the root directory of the command. You can use the which command, for example: which python3

Note: If you do not have permission to modify this file, you can try to use the root user to modify it, or use su to add permissions.

 Note: The command must end with "&" in order to run in the background, otherwise the commands in the rc.local file will block the system startup.

3. Under Centos7, the rc.local file is a soft link. The actual file does not have execution permissions. To set up startup, you need to authorize the file.

# 执行此条命令给文件添加执行权限
chmod +x /etc/rc.d/rc.local

4. Then you can restart and start it again and it will run automatically.

# 重启命令
reboot

Guess you like

Origin blog.csdn.net/weixin_72059344/article/details/131700153