Crontab cannot write to csv.

Asked 2 years ago, Updated 2 years ago, 128 views

I'm a beginner.While looking at the page below, I try to write the temperature to csv once a minute, but the following error occurred in the cron log and I cannot write it.

Note:
Visualize changes in room temperature - sideburns

Mar27 10:56:01 raspberrypi CRON [2995]: (pi) CMD ([2999] python3/home/pi/record_temp.py>/home/pi/temperature.csv)

Mar 27 10:56:01 raspberrypi CRON [2995]: (CRON) error (grandchild #2999 failed with exit status 2)

Mar 27 10:56:01 raspberrypi CRON [2995]: (pi) END ([2999] python3/home/pi/record_temp.py>>/home/pi/temperature.csv)

What should I do?Thank you for your cooperation.

import linecache

DEVICE_NAME='28-00000XXXXXX'

DEVICE_PATH='/sys/bus/w1/devices/'
FILE_NAME='/w1_slave'

class DS18B20:
    def__init__(self):
        self.raw=linecache.getline(DEVICE_PATH+DEVICE_NAME+FILE_NAME, 2) [29:]
        self.value = round (float(self.raw) / 1000.0, 1)

if__name__=="__main__":
    DS = DS18B20()
    print("raw value="+DS.raw)
    print("temperature="+str(DS.value))
import time
import datetime
from DS18B20 import DS18B20

print(str(int(time.mktime(datetime.datetime.now().timetuple()))))+', '+str(DS18B20().value)))
*/1*** python3/home/pi/record_temp.py>/home/pi/temperature.csv

python python3 cron

2022-09-30 13:45

1 Answers

*** python/home/pi/record_temp.py>/home/pi/temperature.csv

What is the environment variable of cron? Is it set so that python can find the executable?
Even so, for your safety, you should write the full path of the command you want to execute.


2022-09-30 13:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.