Search code examples
pythoncronrrdtool

crontab no such file or directory


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


Solution

  • 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.