Running latest version of Rasbian and want to execute /home/pi/temp.py from cron every 2 min. Have chmod 755 on the file
When I run the command from the prompt it executes fine and the script does what it supposed to:
pi@raspberrypi ~ $ python temp.py
I have added it in cron like:
*/2 * * * * /usr/bin/python /home/pi/temp.py
I never get any output from the script. I have other scripts the run fine from cron. What do I miss?
This is what temp.py looks like
!/usr/bin/python
import time
 # Create a unique timestamp for inclusion in the log...
timestamp = time.strftime("Time: %H:%M, Date: %Y%m%d, ")
 # append the filename with the date (this will start a new log daily)...
logname = time.strftime("")
filename = "".join(["/home/pi/bredhult_temp.txt"])
 # If already created, this will open the current log file, if not it will create a new on
datafile = open(filename, "a")
 # open the sensor log file as seen in the tutuorial (replacing 28-000003f1cede with the n
tfile = open("/sys/bus/w1/devices/28-000006879f89/w1_slave")
 # read the data and close the file...
text = tfile.read()
tfile.close()
 # Split the data and extract the temperature value...
temperature_data = text.split()[-1]
temperature = float(temperature_data[2:])
temperature = temperature / 1000
 # write our newly formatted date, time and sensor value to our log file...
datafile.write(timestamp + "Temp: " + str(temperature) + "\n")
datafile.close()
 
     
     
     
     
     
     
    
filename = "".join(["/home/pi/bredhult_temp.txt"])– Bex Mar 27 '15 at 13:16!/usr/bin/pythonshould be#!/usr/bin/python– jDo Apr 21 '16 at 15:17