2

I am trying to bring up a cron job that executes a python script every 5 minutes looking like this:

echo '2-57/5 * * * * $HOME/raspberry_pi/temp_test.py >> $HOME/raspberry_pi/temp_test.log 2>&1' | crontab -

Looking into the generated logfile I am getting this error:

Traceback (most recent call last): File "/home/pi/raspberry_pi/temp_test.py", line 204, in create_graph(temperature, rrd_db) File "/home/pi/raspberry_pi/temp_test.py", line 156, in create_graph 'GPRINT:temp0:LAST:Letzter Messwert: %2.1lf °C') rrdtool.error: opening 'db_test_temp.rrd': No such file or directory

my rrd-database and the python-script that should be executed are in the same directory and I already set the rights of the rrd-file to 777.

I tried out many things while digging in the www ( generating a local cmd-file in the root directory to execute the job, even setting a "cd" in front of the path) but nothing worked. Maybe it's completely obvious and I'm not seeing through because I'm a complete newbie but I would really appreciate any advice.

Thank u very much

asongtoruin
  • 9,794
  • 3
  • 36
  • 47
anatomy
  • 23
  • 1
  • 4
  • Well, maybe a snippet of your code where `db_test_temp.rrd` is used could help. Are you sure that the path to `db_test_temp.rrd` is correct? – rdbisme Aug 08 '17 at 14:17
  • sorry the line the error is referring to is 'DEF:temp0='+rrd_db+':temp0:AVERAGE', and the variable rrd_db is in another referenced to another file (settings.py) rrd_db = "db_test_temp.rrd" – anatomy Aug 08 '17 at 14:27
  • Mmh, maybe edit your question so it will be clear for everyone. Moreover I don't see in your code where you use the `db_test_temp.rrd` file :). It would be great to have the important part of `temp_test.py` – rdbisme Aug 08 '17 at 14:34
  • the reference in the python-script to the settings.py is # Import der Konfigurationsdatei from settings import * ok thank u! i come back when i can make clearer statements :) – anatomy Aug 08 '17 at 14:35
  • def create_graph(temperature, rrd_db): path = "/var/www/html/graph.png" rrdtool.graph(path, '--width', '1000', '--height', '300', '--start', "-86400", '--end', "-1", '--vertical-label', 'Temperatur in °C', '--title', '24h Temperaturverlauf Serverraum', '--lower-limit', '0', 'DEF:temp0='+rrd_db+':temp0:AVERAGE', 'LINE:temp0#FF0000:15 Minuten Durschnittswerte', 'GPRINT:temp0:LAST:Letzter Messwert\: %2.1lf °C') – anatomy Aug 08 '17 at 14:50

1 Answers1

0

The error message is pretty clear: the file db_test_temp.rrd does not appear to exist, though you think it does.

This could be due to several reasons -

  • The file really doesnt exist
  • It does exist, but it is in a different location
  • The process has no permissions on parent directories

The most likely is that you have given the file with no path, which implies it is in the current directory. Most likely, the current directory is not what you are expecting. Unless you are explicitly changing current directory in your script, you are probably somewhere else.

Try specifying the RRD file with full path -- IE, /path/to/file/file.rrd rather than just file.rrd. This will likely solve your problem.

Steve Shipway
  • 3,754
  • 3
  • 22
  • 39