Sometimes,we need to run python scripting manually when our linux machine doing any reboot.
This can be solved with adding the script to rc.local configuration.
this rc file will be run when we doing boot.
To know more about booting process you can read it here.

Ok,here is the step to add the script to rc.local file
For example,i have sd-agent python script for my monitoring stuff.
This file located at my root directory


I need to run the agent.py file everytime my machine start up.
So i will add the script agent.py to rc.local file

# edit the rc.local file
nano /etc/rc.local
# add the url path to the file,make sure you write them above the exit 0 line
cd /root/sd-agent
python ./agent.py start

Note : my agent.py script need to read the file config.cfg , so cd /root/sd-agent on the rc.local configuration is needed because config.cfg is located there.

# make sure the python script running on rc.local file
cd sd-agent
python agent.py stop
ps aux | grep agent

The script has been stopped.
Try to run the script via rc.local file,which is autorun when boot.
/etc/rc.localps aux | grep agent

Ok,so the script has been started when we run the rc.local file

Thank you,share if you like this article !