Raspberry crontab python script at boot
<p>I've been trying to launch a python script at the boot of the Rpi, but everything I've tried until now did not work.</p>

<p>The script is some version of this : <a href="https://www.raspberrypi.org/learning/temperature-log/worksheet/" rel="nofollow">https://www.raspberrypi.org/learning/temperature-log/worksheet/</a> :</p>

<pre><code>#!/usr/bin/python
import os, sys
from subprocess import check_output
from re import findall
from time import sleep, strftime, time

def get_temp():
    temp = check_output(["vcgencmd","measure_temp"]).decode("UTF-8")
    temp = float(findall("\d+\.\d+",temp)[0])
    return(temp)

while True:
    log=open("cpu_temp.txt","a")
    temp = get_temp()
    log.write("{0} {1}".format(strftime("%Y-%m-%d %H:%M:%S"),str(temp))+" degreeC\r\n")
    sleep(60)  
    log.close()
</code></pre>

<p>It works fine on its own. I tried editing crontab, with and without the absolute path to Python, as well as editing /etc/rc.local</p>

<p>I know it doesn't work, because it should create a text file and edit it each minute, and it's not created at boot. I have other commands in crontab and rc.local that are working. </p>

<p>Need some help please !</p>

<p>You can call your script in the <code>~/.bashrc</code> file. It will be called at boot or terminal opening.</p>

<p>Just write :</p>

<pre><code>python /path/to/your/script.py
</code></pre>

<p>At the end of the .bashrc file.</p>

python raspberry-pi crontab boot