I've got a problem with my cronjobs and I'm not able to solve it on my own.
That's what i wrote into crontab -e
(with newline at the end):
SHELL=/bin/bash
*/1 * * * * /home/pi/Projekte/C/CRONTEMP.sh >/dev/null 2>&1
The file "CRONTEMP.sh" contains following:
#!/bin/bash
/home/pi/Projekte/C/Temperaturauslese
exit 0
This Script is working very well when I'm starting it in the terminal.
The File "Temperaturauslese" is a C programm, which I wrote to log any temperature changes in my area ... this is also working very well.
I'm trying to create a statistic about the temperature history in my house and I think without cron it would be much complex.
EDIT: The Problem is that cron is not working.
/var/log/syslog says:
Oct 14 17:37:01 raspberrypi /USR/SBIN/CRON[7203]: (root) CMD (/home/pi/Projekte/C/CRONTEMP.sh)
Oct 14 17:37:01 raspberrypi /USR/SBIN/CRON[7204]: (pi) CMD (/home/pi/Projekte/C/CRONTEMP.sh)
Oct 14 17:37:02 raspberrypi /USR/SBIN/CRON[7201]: (CRON) info (No MTA installed, discarding output)
Oct 14 17:37:02 raspberrypi /USR/SBIN/CRON[7202]: (CRON) info (No MTA installed, discarding output)
EDIT2: sourcecode of Temperaturauslese:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
FILE *Ausgabe, *Temp, *Date;
Temp=fopen("Temp.txt","r");
Ausgabe=fopen("Temperaturverlauf.txt", "a");
Date=fopen("Date.txt","r");
system("python temperaturauslese.py > Temp.txt");
system("date > Date.txt");
double Temperatur=1.1;
char Datum[100];
fscanf(Temp, "%lf", &Temperatur);
/*fprintf(Ausgabe, "%lf\n", Temperatur);*/
fgets(Datum, 100, Date);
fprintf(Ausgabe, "%lf\t%s", Temperatur, Datum);
fclose(Temp);
fclose(Date);
fclose(Ausgabe);
return 0;
}
Sourcecode of temperaturauslese.py:
tfile = open("/sys/bus/w1/devices/10-000802b5cec1/w1_slave")
text = tfile.read()
tfile.close()
temperature_data = text.split()[-1]
temperature = float(temperature_data[2:])
temperature = temperature / 1000
print temperature
PS: THANK YOU FOR YOUR HELP - Solved the problem by using a bash script instead of python :-)
SHELL=/bin/bash
*/1 * * * * /home/pi/Projekte/C/CRONTEMP.sh >/dev/null 2>&1