Reputation: 32001
I am reading data from Google spreadsheet by using python script, the script is working fine when I am running using the shell command but it has not worked when i scheduled it on cron.
so far in check list that i have done
by using tail -f /var/log/syslog | grep CRON
this command i have seen that schedule is fired on time
I have added my script method in a different script which is running fine from cron but still that method not worked in times of cron running
cron statement
/home/ubuntu/.virtualenvs/python_3.5/bin/python /location/script_name.py
Is there any other way to check this why it is not working from cron schedule but working fine from shell command.
Upvotes: 1
Views: 454
Reputation: 32001
After getting the suggestion from @stovfl i added >> /tmp/cron.log 2>&1
this line
/home/ubuntu/.virtualenvs/python_3.5/bin/python /location/script_name.py >> /tmp/cron.log 2>&1
with my cron statement and check the log file and i found i have not used explict path for authentication json file though it is inside project folder so times of shell command it it was working fine. used code just like below
credentials = ServiceAccountCredentials.from_json_keyfile_name('file_name.json')
and therefore when cron fired the scrip it failed to get the authetication file location and not ran. then i changed like below
credentials = ServiceAccountCredentials.from_json_keyfile_name('location_of_file/file_name.json')
now it works like a charm from cron and shell command
Upvotes: 1