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

General discussion • Run Python 3 Program at Raspberry Pi Boot Up

$
0
0
I have a python 3 program I want to start running when the raspberry pi boots up

I can enter sudo python3 pythonclock.py and the program runs as expected.

I created a a file name runclock.sh in the /home/walli directory
the contents of runclock.sh are:
#!/bin/sh
cd /
cd /home/walli
sudo python3 pythonclock.py

I can type bash runclock.sh and the program starts and runs as expected

I used nano to edit the /etc/rc.local file and added the line: /home/walli/runclock.sh &
(the above line was added above the exit 0 line that was already in rc.local)

When I re-boot the Raspberry Pi, the program pythonclock.py does not start.

I also tried adding the following line to crontab:
@reboot /home/walli/runclock.sh
also tried :
@reboot /home/walli/bash runclock.sh

This does work either.
Any help would be much appreciated

Statistics: Posted by Aggie64 — Sun Feb 02, 2025 4:07 pm — Replies 3 — Views 69



Viewing all articles
Browse latest Browse all 4491

Trending Articles