I would like to run the python script, when I startup the Linux machine. How can I do so? I don't need the user to login the OS to start the script. (The user is password protected.)
Asked
Active
Viewed 4,675 times
1 Answers
5
Generic method – add the script to /etc/rc.local:
/usr/bin/python pythonscript.py
if your python interpreter is under /usr/bin, or simply
/path/to/pythonscript.py
if your script is marked executable (+x).
Note that some systems use /etc/rc.d/rc.local instead.
On systemd systems, rc.local might be ignored completely.
Create a service unit, /etc/systemd/system/something.service:
[Unit] Description=Script name [Service] ExecStart=/path/to/script.py [Install] WantedBy=multi-user.target
Tell systemd to start the script on boot with systemctl enable something.service.