Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8609

Python • Autostart a Python file on startup

$
0
0
Hello,

I use a Raspberry Pi zero w with a Bonnet-hat to run my rgb-led-matrix.
I installed Debian Bookworm without GUI.
Normal running is no problem.
Now I want to start the python file from startup.
I first tried to use rc.local with the following script:
python3 /home/lo/rpi-rgb-led-matrix/bindings/python/samples/runtext.py -m=adafruit-hat --led-rows=16 --led-cols=32 --led-slowdown-gpio=0 &

exit 0

After reboot nothing happens

Then I tried Crontab
From the command line I typed:
crontab -e

I choose nano
The code:
@reboot /home/lo/rpi-rgb-led-matrix/bindings/python/samples/runtext.py

After reboot, nothing happens.

Then I tried with systems
I created a Systemd service file witch I stored in de etc/systemd/system directory as python-script.service
The code:
[Unit]
After=network.target

[Service]
ExecStart=/home/lo/rpi-rgb-led-matrix/bindings/python/samples/runtext.py

[Install]
WantedBy=default.target

Then I typed in the cmd the following commands:
$ sudo chmod 744 /home/lo/rpi-rgb-led-matrix/bindings/python/samples/runtext.py
$ sudo chmod 664 /etc/systemd/system/python-script.service

$ sudo systemctl daemon-reload
$ sudo systemctl enable python-script.service

I reboot the system and nothing happens.

So I do something wrong, but I have no idea what.

I hope somebody can give me some help.

Thank you.

Statistics: Posted by lodv — Sat Jul 05, 2025 1:26 pm



Viewing all articles
Browse latest Browse all 8609

Trending Articles