0

I have a Python script that runs from the command line beautifully, but when I try and run it from CRON does strange things.

The script generates, then runs an apk script file.

The apk script file is saved in /usr/src/scripts/plots/core_temp_data/weeklyplots when run via the command line; but it is saved in /home/pi when run from CRON.

I've also tried writing the CRON errors to a logfile, but that is placed in the /home/pi directory too!

The script is working, but saving the resultant files in the wrong place, so how do I specify the correct path?

I've tried searching for how to specify the path, but got myself horribly confused.

The part of the script that generates the apk script is fout = open("live_gnu_command.gpl", "w")

following D_byes help this worked: fout = open("/usr/src/scripts/plots/core_temp_data/weeklyplotslive_gnu_command.gpl", "w")

2

By default, cron runs all jobs in the home directory of the user who owns the job. Make sure that your python script uses absolute paths when writing the output files, or it'll put them in the current user's home directory.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.