0

I have applied the solution to my question:

  1. https://stackoverflow.com/questions/25902905/python-writing-to-file-works-fine-when-done-manually-but-cron-fails

but it has not resolved.

I wish to save the file at the following location :

/home/user/Documents/Python/output.csv

Path of the script:

/home/user/Documents/Python/script.py

my cronjob

* * * * * * /usr/bin/python3 /home/user/Documents/Python/script.py 

It saves the data in a new file created on the following location if I give relative path:

/home/user/output.csv

and I do not want to give absolute path for the output file.

4
  • Did you try relative (to your home directory) path? – FedonKadifeli May 9 '20 at 15:15
  • It saves to the home directory, but I wish to save the file the above mentioned location. – Akshat Zala May 9 '20 at 16:11
  • 1
    You haven't told us how your python script decides where to write its output - if it simply creates output.csv in its working directory, then the easiest way to handle that is to change the directory before running it ex. cd /home/user/Documents/Python && /usr/bin/python3 /home/user/Documents/Python/script.py or equivalently cd /home/user/Documents/Python && /usr/bin/python3 script.py – steeldriver May 9 '20 at 16:12
  • Thanks @steeldriver the crontab is saving the output in the same directory – Akshat Zala May 10 '20 at 9:46

Your Answer

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

Browse other questions tagged or ask your own question.