【发布时间】:2015-10-15 20:01:00
【问题描述】:
我正在通过 Centos6 远程服务器上的 cron 作业运行 Python feedparser 脚本(通过 SSH 连接到服务器)。
在 Crontab 中,这是我的 cron 工作:
MAILTO = myemail@company.com
*/10 * * * * /home/local/COMPANY/malvin/SilverChalice_CampusInsiders/SilverChalice_CampusInsiders.py > /home/local/COMPANY/malvin/SilverChalice_CampusInsiders`date +\%Y-\%m-\%d-\%H:\%M:\%S`-cron.log | mailx -s "Feedparser Output" myemail@company.com
但是,我在发送的电子邮件中看到了这条消息,它应该只包含脚本的输出:
Null message body; hope that's ok
/usr/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Traceback (most recent call last):
File "/home/local/COMPANY/malvin/SilverChalice_CampusInsiders/SilverChalice_CampusInsiders.py", line 70, in <module>
BC_01.createAndIngest(name, vUrl, tags, desc)
File "/home/local/COMPANY/malvin/SilverChalice_CampusInsiders/BC_01.py", line 69, in createAndIngest
creds = loadSecret()
File "/home/local/COMPANY/malvin/SilverChalice_CampusInsiders/BC_01.py", line 17, in loadSecret
credsFile=open('brightcove_oauth.json')
IOError: [Errno 2] No such file or directory: 'brightcove_oauth.json'
通常,这将是一个不费吹灰之力的问题:我的代码一定有问题。除了,当我通过python SilverChalice_CampusInsiders.py在命令行上运行该脚本时,该脚本运行良好
我在这里做错了什么?为什么 Python 脚本在通过 cron 作业运行时看不到 json oauth 文件?
【问题讨论】:
标签: python python-2.7 cron centos6