I am trying to run some jobs in django-crontab. They have been added successfully. Here is the code snippet.
CRONJOBS = [
('0 0 * * *', 'landingpage.my_crons.get_users','>> /home/root_user/scheduled_job.log'),
('0 0 * * *', 'landingpage.my_crons.data_collector'),
]
crons appear when i do crontab show
8e70613793052f5793f86106c92994fe -> ('0 0 * * *', 'landingpage.my_crons.get_users', '>> /home/root_user/scheduled_job.log')
d72fb010328cdc02e4b984fdc5f7db05 -> ('0 0 * * *', 'landingpage.my_crons.data_collector')
when I run these using hashes they run fine and write files fine but when they run as scheduled they don't write files Even though it is empty but log file is being generated which means jobs are running but they are unable to write files that are being generated by script. Files are csv files based on bigquery data
Most likely, the issue will be due to the fact that crontab works with absolute path, so the generated csv will be in your home directory. To resolve this, use the Pathlib library to get the absolute path and you can then concatenate it with your desired output folder.