python rc.local
时间: 2023-09-28 12:07:47 浏览: 103
rc-local.service
rc.local is a script file that is executed by the Linux system on boot. It is used to run commands or scripts that need to be executed at system startup, such as mounting file systems, starting services, or configuring network interfaces.
In Python, you can add commands to the rc.local file by editing the file using a text editor such as nano or vi. Here's an example of how to add a Python script to rc.local:
1. Open the rc.local file using a text editor:
```
sudo nano /etc/rc.local
```
2. Add the Python script that you want to run at startup, for example:
```
python /path/to/my_script.py &
```
3. Save the file and exit the text editor.
The ampersand (&) at the end of the command is used to run the script in the background, so that the startup process won't be blocked by the script.
Note that the rc.local file must be executable, so you may need to change the permissions of the file using the following command:
```
sudo chmod +x /etc/rc.local
```
Once you've added your Python script to rc.local, it will be executed every time the system boots up.
阅读全文