Raspberry Pi Auto-Start Python using Cron

nano start.sh

#!/bin/sh
cd /
cd home/pi
sudo python test.py
cd /

chmod 755 start.sh

mkdir logs

sudo crontab -e
last line:
@reboot sh /home/pi/start.sh >/home/pi/logs/cronlog 2>&1

Using this way, we create a one-time only cron. Note that it works in background.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s