简体   繁体   English

crontab 没有读取文件的权限

[英]Crontab doesn't have permission to read a file

i need to calculate the percentage difference between yesterday bitcoin price and current price.我需要计算昨天比特币价格和当前价格之间的百分比差异。

I have a python script and the current price is given by:我有一个 python 脚本,当前价格由下式给出:

 response = requests.get('http://api.coindesk.com/v1/bpi/currentprice.json')

but i don't know how to get yesterday price.但我不知道如何获得昨天的价格。 The only way that i found is saving the current price in a txt file and updating it every day.我发现的唯一方法是将当前价格保存在 txt 文件中并每天更新。 The problem is with crontab that doesn't have the access to the file and can't read this line.问题在于 crontab 无法访问该文件并且无法读取此行。

file = open("yesprice.txt", "r")

how can i fix this?我怎样才能解决这个问题?

chmod a+r yesprice.txt Should do the trick. chmod a+r yesprice.txt应该可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM